sizeof compile time Operator and comma operator in C

sizeof:  sizeof is a unary compile time operator. It returns number of the bytes of the variables. Example:

double a;

printf(“%d “, sizeof a);

printf(“%d”, sizeof(int));

Output: 8 4

Since double is 8 bytes and int is 4 bytes.

Comma operator: Comma operator is used to hold several expressions together and it is used for a sequence of operations. Left side of comma operator is void and right side becomes value of total expression. Example:

a = (b=10, b-1);

Evaluation: First b is assigned value of 3 and then a is assigned the value of 9.

Leave a Reply