What are Operators ?

C Special Operator – &, *, sizeof, etc.

Apart from arithmetic, relational, logical, assignment, etc. operators, C language uses some other operator such as:

  1. sizeof operator
  2. & operator
  3. * operator
  4. The . (dot) and -> (arrow) operators
  5. [] operator, etc.

sizeof to find size of any entity(variable, array, etc.), & operator to find address of a variable, etc. You can see a list of such operators in the below table.

sizeofreturns the size(length in bytes) of entity, for eg. a variable or an array, etc.sizeof(x) will return size of the variable x
&returns the memory address of the variable&x will return address of the variable x
*represents pointer to an object. The * operator returns the value stored at a memory address.m = &x (memory address of variable x)*m will return the value stored at memory address m
. (dot) operatorused to access individual elements of a C structure or C union.If emp is a structure with an element int age in it, then emp.age will return the value of age.
-> (arrow) operatorused to access structure or union elements using a pointer to structure or union.If p is a pointer to the emp structure, then we can access age element using p->age
[] operatorused to access array elements using indexingif arr is an array, then we can access its values using arr[index], where index represents the array index starting from zero

We will learn about *, dot operator, arrow operator and [] operator as we move on in this tutorial series, for now let’s see how to use the sizeof and & operators.

Example: Using sizeof and & Operators

Here is a code example, try running in the live code compiler using the Run code button.

#include <stdio.h>

int main() {

   int a = 20;
   char b = 'B';
   double c = 17349494.249324;

   // sizeof operator
   printf("Size of a is: %d \n", sizeof(a));
   printf("Size of b is: %d \n", sizeof(b));
   printf("Size of c is: %d \n", sizeof(c));

   // & operator
   printf("Memory address of a: %d \n", &a);

   return 0;



Size of a is: 4 Size of b is: 1 Size of c is: 8 Memory address of a: 1684270284

Leave a Reply

Your email address will not be published. Required fields are marked *