C Programming Questions and Answers – Float Datatype – 2

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Float Datatype – 2”.

Pre-requisite for C Float Datatype MCQ set: Video Tutorial on C Data Types.

1. What will be the output of the following C code?

    #include <stdio.h>
    printf("%.0f", 2.89);

a) 2.890000
b) 2.89
c) 2
d) 3
View Answer

Answer: d
Explanation: None.

2. What will be the output of the following C code?

advertisement
advertisement
Note: Join free Sanfoundry classes at Telegram or Youtube
  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         float a = 2.455555555555;
  5.         printf("%f", a);
  6.     }

a) 2.455555
b) 2.455556
c) 2.456
d) 2.46
View Answer

Answer: a
Explanation: None.
advertisement

3. Which of the following % operation is invalid?
a) 2 % 4;
b) 2 % 4l;
c) 2 % 4f;
d) Both 2 % 4l; and 2 % 4f;
View Answer

Answer: c
Explanation: None.

4. Which data type is suitable for storing a number like?

10.0000000001

a) int
b) float
c) double
d) both float and double
View Answer

Answer: c
Explanation: None.
advertisement

5. Modulus for float could be achieved by?
a) a % b
b) modulus(a, b);
c) fmod(a, b);
d) mod(a, b);
View Answer

Answer: c
Explanation: None.

6. Predict the data type of the following mathematical operation?

2 * 9 + 3 / 2 . 0

a) int
b) long
c) float
d) double
View Answer

Answer: d
Explanation: None.

7. %lf is used to display?
a) float
b) long float
c) double
d) all of the mentioned
View Answer

Answer: c
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.