Test Series - cpp

Test Number 12/102

Q: 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
Solution: Floating point types occur in only three sizes-float, long double and double.
Q: Which of the following is a valid floating-point literal?
A. f287.333
B. F287.333
C. 287.e2
D. 287.3.e2
Solution: To make a floating point literal, we should attach a suffix of ‘f’ or ‘F’ and there should not be any blank space.
Q: 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
Solution: This is the defined range of floating type number sin C++. Also range for +ve and -ve side should be same so the answer is -3.4E+38 to +3.4E+38.
Q: 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
Solution: Float for single precision, double for double precision and long double for extended precision.
Q: Which is used to indicate single precision value?
A. F or f
B. L or l
C. Either F or for L or l
D. Neither F or for L or l
Solution: Either F or f can be used to indicate single precision values.
Q: Which is correct with respect to the size of the data types?
A. char > int < float
B. int < char > float
C. char < int < float
D. char < int < double
Solution: The char has less bytes than int and int has less bytes than double whereas int and float can potentially have same sizes.
Q: The size of an object or a type can be determined using which operator?
A. malloc
B. sizeof
C. malloc
D. calloc
Solution: The sizeof operator gives the size of the object or type.
Q: It is guaranteed that a ____ has at least 8 bits and a ____ has at least 16 bits.
A. int, float
B. char, int
C. bool, char
D. char, short
Solution: char types in C++ require atleast 8 bits and short requires atleast 16 bits, whereas for bool only 1 bit suffices and both int and float requires atleast 32 bits.
Q: Implementation dependent aspects about an implementation can be found in ____
A. 
B. 
C. 
D. 
Solution: The limit header holds the details of the machine dependent details.
Q: Size of C++ objects are expressed in terms of multiples of the size of a ____ and the size of a char is _______
A. char, 1
B. int, 1
C. float, 8
D. char, 4
Solution: Each object in C++ is expressed in terms of char type and size of char type is one byte.

You Have Score    /10