C Programming Multiple Choice Questions and Answers on Float Datatype for Freshers

1. The number of digits present after decimal in float is________

a) 1
b) 3
c) 6
d) 16
Answer: c
2. Which among the following is never possible as an output for float?

a) 3.666666
b) 3.666
c) 3
d) None of the mentioned
Answer: d
3. In a 32-bit compiler, which 2 types have same size?

a) char and short
b) short and int
c) int and float
d) float and double
Answer: c
4. What is the size of float in a 32-bit compiler?

a) 1
b) 2
c) 4
d) 8
Answer: c
5. Loss in precision occurs for typecasting from____________

a) char to short
b) float to double
c) long to float
d) float to int
Answer: d
6. For union
  1.  union temp
  2.     {
  3.         char a;
  4.         int b;
  5.         float c;
  6.     };
The size is decided by:
a) char
b) int
c) float
d) both int and float
Answer: d
7. %f access specifier is used for

a) Strings
b) Integral types
c) Floating type
d) All of the mentioned
Answer: c
8. Select the odd one out with respect to type?

a) char
b) int
c) long
d) float
Answer: d
9. What is the output of this C code?
  1.     #include 
  2.     printf("%.0f", 2.89);
a) 2.890000
b) 2.89
c) 2
d) 3
Answer: d
10. What is the output of this C code?
  1.     #include 
  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
Answer: a
11. 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
12. 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
13. Modulus for float could be achieved by?

a) a % b
b) modulus(a, b);
c) fmod(a, b);
d) mod(a, b);
Answer: c
14. Predict the data type of the following mathematical operation?
    2 * 9 + 3 / 2 . 0

a) int
b) long
c) float
d) double
Answer: d
15. %lf is used to display

a) float
b) long float
c) double
d) all of the mentioned
Answer: c

Related

Multiple Choice Questions 6857644913722072469

Post a Comment

emo-but-icon

item