Here is a listing of C Objective Questions on “Float Datatype” along with answers, explanations and/or solutions:
1. What will be the output of the following C code?
#includeprintf("%.0f", 2.89);
a) 2.890000
b) 2.89
c) 2
d) 3
Answer: d
Clarification: None.
2. What will be the output of the following C code?
-
#include
-
int main()
-
{
-
float a = 2.455555555555;
-
printf("%f", a);
-
}
a) 2.455555
b) 2.455556
c) 2.456
d) 2.46
Answer: a
Clarification: None.
3. Which of the following % operation is invalid?
a) 2 % 4;
b) 2 % 4l;
c) 2 % 4f;
d) Both 2 % 4l; and 2 % 4f;
Answer: c
Clarification: 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
Answer: c
Clarification: None.
5. Modulus for float could be achieved by?
a) a % b
b) modulus(a, b);
c) fmod(a, b);
d) mod(a, b);
Answer: c
Clarification: None.
6. Predict the data type of the following mathematical operation?
2 * 9 + 3 / 2 . 0
a) int
b) long
c) float
d) double
Answer: d
Clarification: None.
7. %lf is used to display?
a) float
b) long float
c) double
d) all of the mentioned
Answer: c
Clarification: None.