Open In App

GFact | (Sizeof) is an operator

Improve
Improve
Like Article
Like
Save
Share
Report

In C language, sizeof( ) is an operator. Though it looks like a function, it is an unary operator.

For example in the following program, when we pass a++ to sizeof, the expression “a++” is not evaluated. However in case of functions, parameters are first evaluated, then passed to function.




// C program to demonstrate that sizeof
// is an operator
#include<stdio.h>
  
int main()
{
    int a = 5;
    printf("%d\n", (int)sizeof(++a));
    printf("%d", a);
    return 0;
}


Output :

4
5

This article is contributed Shivam Gupta.


Last Updated : 18 Oct, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads