G-Fact 1 | (Sizeof is an operator)

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

4
5

This article is contributed Shivam Gupta. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above



My Personal Notes arrow_drop_up

Improved By : Shubham_Menkudle



Article Tags :

3


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.