C sizeof() function

  • By using sizeof() function, we can find the size of given argument.
  • sizeof function always returns unsigned int value which value is greater than zero(0).


voind main()
int i;
float f;
char ch;
printf(“\n size of int: %d”,sizeof(i));
printf(“\n size of float: %d”,sizeof(f));
printf(“\n size of char: %d”,sizeof(ch));


size of int:2
size of float:4
size of char:1

Few More Examples:

sizeof(25) — 2
sizeof(25u) — 2
sizeof(25l) — 4
sizeof((25lu) — 4
sizeof(short) — 2
sizeof(long) — 4
sizeof(signed) — 2
sizeof(unsigned) — 2
sizeof(char) –1
sizeof((‘A’) –2(because sizeof(65) -2)

Note: in sizeof function all expression can be evaluated except assignment operator.


void main()
int a;
printf(“\n size of a:%d”,sizeof(++a));

Powered by k2schools