in Programming in C retagged by
2,488 views
4 votes
4 votes

What will be output if you will compile and execute the following C code? 

void main() 
{
printf("%d",sizeof(5.2));
}
  1. $4$
  2. $8$
  3. $2$
  4. $16$
in Programming in C retagged by
by
2.5k views

7 Answers

3 votes
3 votes
Any decimal by default is treated as double, if it was sizeof(5.2f), it would return size of float datatype.

Question should mention size of double type data as it depends on platform. As its not mentioned it can be B or D. Reason for this is as per C standard double should be atleast 8B. (of course some compiler may ignore this).

1 comment

here 5.2 are not specifying.you cant say it is double or float,

official ans key was option A

CORRECT ME IF I AM WRONG
1
1
1 vote
1 vote
8 bytes sizeof float
0 votes
0 votes
b and  d depending upon the operating system of the computer,
 if the arcitecture is 64 bit then ans d if 16bit ans b
0 votes
0 votes

OPTION A

Size of is a special operator will return number of bytes of data types. By default system will take integer data type, if we are not specifying any datatype. Total size is 4 bytes.

Answer:

Related questions