Floating Point Types C++ MCQ

Errorlogger
0
1. Which of the following is not one of the sizes of the floating point types?
a) short float
b) float
c) long double
d) double

Answer:a


2. Which of the following is a valid floating point literal?
a) f287.333
b) F287.333
c) 287.e2
d) 287.3.e2

Answer:c


3. What is the range of the floating point numbers?
a) -3.4E+38 to +3.4E+38
b) -3.4E+38 to +3.4E+34
c) -3.4E+38 to +3.4E+36
d) -3.4E+38 to +3.4E+32

Answer:a


4. Which of three sizes of floating point types should be used when extended precision is required?
a) float
b) double
c) long double
d) extended float

Answer:c


5. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         float num1 = 1.1;
  6.         double num2 = 1.1;
  7.         if (num1 == num2)
  8.            cout << "Vansh";
  9.         else
  10.            cout << "Sharma";
  11.         return 0;
  12.     }
a) Vansh
b) Sharma
c) compile time error
d) runtime error

Answer:a


6. What is the output of this program?
  1.     #include <iomanip>
  2.     #include <iostream>
  3.     using namespace std;
  4.     int main()
  5.     {
  6.         cout << setprecision(17);
  7.         double d = 0.1;
  8.         cout << d << endl;
  9.         return 0;
  10.     }
a) 0.11
b) 0.10000000000000001
c) 0.100001
d) compile time error

Answer:b


7. What is the output of the following program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         float i = 123.0f;
  6.         cout << i << endl;
  7.         return 0;
  8.     }
a) 123.00
b) 1.23
c) 123
d) compile time error

Answer:c


8. Which is used to indicate single precision value?
a) F or f
b) L or l
c) either a or b
d) neither a or b

Answer:a


9. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         float f1 = 0.5;
  6.         double f2 = 0.5;
  7.         if (f1 == 0.5f)
  8.             cout << "equal";
  9.         else
  10.             cout << "not equal";
  11.         return 0;
  12.     }
a) equal
b) not equal
c) compile time error
d) runtime error

Answer:a


10. Which is correct with respect to size of the datatypes?
a) char > int < float
b) int < char > float
c) char < int < float
d) double < char > int

Answer:c
Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !