Sizeof operator in C and C++

In the programming languages C and C++, the unary operator sizeof is used to calculate the size of any datatype.

Example

#include<stdio.h>
int main()
{		
     int a;
     char b;
     long c;
     float d;
     
     /* Calculating by Directly data type */
     printf("Size of Character (char) %d\n",sizeof(char));     
     printf("Size of int %d\n",sizeof(int));
     printf("Size of long %d\n",sizeof(long));
     printf("Size of float %d\n",sizeof(float));
     
     /* Calculating by Variable names*/
     printf("Size of Character (char) %d\n",sizeof(b));     
     printf("Size of int %d\n",sizeof(a));
     printf("Size of long %d\n",sizeof(c));
     printf("Size of float %d\n",sizeof(d));
     
     getchar();
     return 0;
}

Output on a Window Operating System

Size of Character (char) 1
Size of int 4
Size of long 4
Size of float 4
Size of Character (char) 1
Size of int 4
Size of long 4
Size of float 4