C Sizeof Operator

The C Sizeof operator is one of operators which is mostly useful to find the array size, structure size, and do some calculations as per the results.

The C sizeof operator returns the size (number of bytes) of a declared variable or data type. Let us see one C programming example for better understanding

C Sizeof Operator Example

In this Operator example program, We are going to check the size of an integer, float, character, double and character array using sizeof operator.

#include <stdio.h>

int main()
  int a;
  int b[20];
  printf(" Size of int data type:%d \n ", sizeof(int) );
  printf(" Size of char data type:%d \n ", sizeof(char) );
  printf(" Size of float data type:%d \n ", sizeof(float) );
  printf(" Size of double data type:%d \n ", sizeof(double) );

  printf(" Size of int data type:%d \n ", sizeof(a) ); 
  printf(" Size of an int array:%d \n ", sizeof(b) );
  return 0;
C SizeOf Operator

The result of sizeof(b): Although we declared the size of the b as 20, it displays output as 80. Because b array will store 20 integer members. And every integer member needs 4 bytes of space ( means 20 * 4 Bytes for every integer member.)