What will be the output of the program in 16-bit platform (Turbo C under DOS) ?
#include <stdio.h>
int main()
{
printf("%d, %d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0));
return 0;
}
Answer: B
Correct answer: 4, 2, 8
On a 16-bit Turbo C target: 3.0f is a float, 4 bytes; '3' is a character constant, which has type int in C, so 2 bytes on that platform - not 1; and 3.0 with no suffix is a double, 8 bytes. The character constant is the trap: it is an int in C and a char only in C++.
Please log in or register to report this question.