Special Operators


sizeof operator returns the number of bytes that will be used to represent the operand. The operand can be an expression or a type name. For example sizeof(int) will return the number to bytes used by an integer (generally 4). You can also use this operator to get the size of a structure or union.

If the operand of sizeof operator is an expression, the compiler will not evaluate the expression but will determine the type of the expression and returns the size of that type.

If the operand is an array then result will be number of items in the array multiplied by the size of a single element in the array.

The following program prints the sizeof different types of operands

#include <stdio.h>
int main() {

char c;
int i[10];
printf("Size of a char data type is %d \n", sizeof(char));
printf("Size of int data type is %d \n", sizeof(int));
printf("Size of data type of variable c is %d \n", sizeof(c));
printf("Size of the data type of the expression is %d \n", sizeof(c + 1));
printf("Size of an integer array is %d \n", sizeof(i));

return 0;

Output of the above program is

Size of a char data type is 1
Size of int data type is 4
Size of data type of variable c is 1
Size of the data type of the expression is 4
Size of an integer array is 40

Comma Operator

The comma operator (,) will evaluate a sequence of expressions from left to right. The result of each of the expression is discarded. The final return value and type will be that of the right most expression. The expressions should be enclosed in parenthesis because the comma operator has the least precedence among C operators.


d = (a=5, a+1, a+2);

In the above example the first expression used with the comma operator is a=5 that is evaluated first and a is assigned the value 5. The second expression will add 1 to a. The third expression will add 2 to variable a which already has the value 5. The final result becomes 7 and this result is assigned to variable d. So value of d is 4.

Cast Operator

Cast operator will convert the type of one variable to another.


float a;
int b;
a = 5.2;
b = (int) a;

In this example variable a which is of type float is converted to an integer. The value of b will be 5.

Address of Operator ( & )

The address of operator & will return the address of the operand\'s memory location. For example &a will return the memory address where the variable a is stored.

Array Operator ( [] )

The array operators [] are used to reference the member of an array. The first element of an array named a can be referenced as a[0] and a[5] will refer to the 6th member of the array.

Pointer Operator ( * )

The * operator is used to declare a pointer variable that can store the address of a variable. It is also used in a different context to returns the value stored at the address held by a pointer variable.

#include <stdio.h>
int main() {

int a=10;
int *aptr;
aptr = &a;
printf("aptr = %d",* aptr);

return 0;

This program will output

aptr = 10

Post a comment


Your Comment

Email (We dont publish it)


Monika | February 9, 2017 12:41 PM |

Could u provide some more programs on c