Sizeof operator calculate the size of data i.e. how many bit a specific data having.
Syntax of sizeof operator :
printf("<format string>",sizeof<(data type variable)>);
/*Program to sizeof operator*/
#include<stdio.h>
#include<conio.h>
void main()
{
int x=10;
clrscr();
printf("\nSize of x is %d",sizeof(x));
getch();
}
Output of above program :
Size of x is 2
We read in data type chapter that an int allocate only 2 byte in memory,Hence, x = 2.
Comments
Post a Comment