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*/
 void main()
  int x=10;
  printf("\nSize of  x is %d",sizeof(x));

  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