Arrange the following data types in non-decreasing order according to the length of their representation in C++.
A. char
B. int
C. float
D. double
Choose the correct answer from the options given below:
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. A, B, C, D
Explanation
On a typical C++ implementation, char occupies 1 byte, int and float each occupy 4 bytes, and double occupies 8 bytes. Arranging these sizes in non-decreasing order gives char (1) ≤ int (4) = float (4) ≤ double (8), which corresponds to the sequence char, int, float, double. Any ordering that places a larger type before a smaller one, such as int before char or double before float, violates the non-decreasing requirement. So the correct order is A, B, C, D.More Programming Languages and Computer Graphics questions
- Which of the following would be the value of z for the C program code? x = 16; y = 4; z = x >> y;
- What will be the output of the following program? #include<stdio.h> int main() { int i; for (i = 0; i++<10; ) printf("%d", i++); return 0; }
- Match the LIST-I with LIST-II. LIST-I LIST-II A. Pivot point I. Reflection B. Fixed point II. Shear C. Mirror image III. Rotation D. Distor…
- The number of pixel columns divided by the number of scan lines that can be displayed by the system, is called
- The above figure shows a triangle at an original position (vertices labelled 2, 1, 3) to the left of the y-axis, and the same triangle, fil…
- What will be the output of the following C programming code:int i, j; for(i=1; i<5; i+=2) for(j=1; j<i; j+=2) printf("%d", j);