• Post author:
  • Reading time:1 mins read
  • Post category:C Programs

In C programming language you can check the size of a variable using sizeof operator. In order to use sizeof the zoperator, you can pass variable to the operator.

Example: sizeof(var1);

sizeof is not a function. You can directly pass a type like: sizeof(int); .

Find the Size of a Variable in c Programming


int main()
  int var1=123;
  printf("The size of var1 is %d\n",sizeof(var1));
  return 0;


C program to find the size of a variable

Code Explanation

First, declare an int type variable. Then using printf() function print “The size of var1 is” . By using sizeof() operator print the size of an int type variable onto the console.

People also ask

What is sizeof() operator?

The sizeof is a keyword that determines size of a variable or datatype.

What is the type of sizeof?

sizeof is an unary operator in C.