Thursday, September 3, 2015

sizeof operator in C (MCA I)

sizeof operator

  1. sizeof operator is used to calcualte the size of data type or variables.
  2. sizeof operator can be nested.
  3. sizeof operator will return the size in integer format.
  4. sizeof operator syntax looks more like a function but it is considered as an operator in c programming

Example of sizeof() operator

Size of Variables

#include<stdio.h>

int main() {

   int ivar = 100;
   char cvar = 'a';
   float fvar = 10.10;

   printf("%d", sizeof(ivar));
   printf("%d", sizeof(cvar));
   printf("%d", sizeof(fvar));
   return 0;
}

No comments:

Post a Comment