Sizeof Operator in C programming language

sizeof operator in c programming language

Sizeof Operator in C programming:

  • sizeof operator used to calculate the sizeof variable, constant or datatype
  • its unary operator means works on a single operand
  • sizeof operator returns the size of given input

Syntax :

result = sizeof(typeName)

typeName can be variable, constant or datatype.

Example :

printf(“Size of Integer : %ld \n”, sizeof(int))

Output :

Size of Integer: 4

Note: If you may thinking why I used %ld format specifier Because sizeof operator returns the output in size_t  format. it is an unsigned int  format.

Program to calculate the sizes of all data types :

Output :

Note: I am using GCC compiler on Ubuntu system with 64 bit OS. So if you use any other compiler like turbo C, your output might differ. But you need to note that sizes of datatypes are platform depended.

Fun Fact :

sizeof operator looks like a Function ( because of the parenthesis ) but it’s an operator.



Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

6 Responses


    what would be the output of following program
    int main()

  1. […] Sizeof Operator. […]

  2. […] are going to use the in-built C language sizeof operator to calculate the size of each […]

  3. […] Sizeof Operator. […]

  4. […] it will use the calloc() function to create the nChunks memory, where each chunk is equal to the sizeof the integer […]

  5. […] can also use the sizeof() operator to properly allocate the memory. For example, If you want to allocate memory for 90 integers, Then […]

Leave a Reply