9.09.2011

Sizeof operator


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.

No comments:

Post a Comment