Q. Which of the following is the correct output for the program given below?
Code:#include <stdio.h>
int main ( )
{
printf ("%d %d %d\n" , sizeof(2.19f), sizeof(2.19), sizeof (2.19l));
return 0 ;
}
β
Correct Answer: (B)
4 8 8
Explanation:
The sizeof() operator returns the size (in bytes) of a data type or expression. Let's analyze each argument inside printf:
Breakdown of sizeof() calls:
- sizeof(2.19f) β 2.19f is a float, which typically takes 4 bytes.
- sizeof(2.19) β 2.19 is a double (default type for floating-point literals in C), which typically takes 8 bytes.
- sizeof(2.19l) β 2.19l (or 2.19L) is a long double, which usually takes 10 bytes on most systems (but may be 12 or 16 bytes on some architectures).
Thus, the output is 4 8 10.