Sizeof Operator : Integer,Float,Char : C General Multiple Choice Question



Sizeof Operator : Integer,Float,Char  : C General Multiple Choice Question


What would be the Output of this Program ?

#include<stdio.h>
void main()
{
char cvar='a';
int ivar=10;
float fvar=10.1;

printf("\nSizeof(ivar) : %d Byte",sizeof(ivar));
printf("\nSizeof(cvar) : %d Bytes",sizeof(cvar));
printf("\nSizeof(fvar) : %d Bytes",sizeof(fvar));
}

Output :

Sizeof(ivar) : 2 Byte
Sizeof(cvar) : 1 Bytes
Sizeof(fvar) : 4 Bytes

Why ?

  1. 2 bytes of Memory Required for Storing Integer
  2. Just 1 byte is required to Store Character Type Variable
  3. Allas… Float Requires 4 bytes.