Sizeof Operator : Passing Actual Value : C General Multiple Choice Question >> Part 3



Sizeof Operator : Passing Actual Value : C General Multiple Choice Question >> Part 3


What would be the Output of this Program ?

#include<stdio.h>
void main()
{
char y='a';
int x=10;
float z=10.1;
printf("\nSizeof(10) : %d Byte",sizeof(10));
printf("\nSizeof('a') : %d Bytes",sizeof('a'));
printf("\nSizeof(10.1) : %d Bytes",sizeof(10.1));
}

Output :

Sizeof(10) : 2 Byte
Sizeof('a') : 1 Bytes
Sizeof(10.1) : 4 Bytes

[toggle title=”Output”]

Sizeof(10) : 2 Byte
Sizeof('a') : 1 Bytes
Sizeof(10.1) : 4 Bytes

[/toggle]


Why ?

  1. Integer Occupies 2 bytes of Memory [ Borland CC++ 3.0 ]
  2. Character Occupies 1 bytes of Memory
  3. Float Occupies 4 bytes of Memory