c program to find size of variable

In this example, We simply display size of int, float, double and char in byes with sizeof() operator.

Sizeof Operator in C Language

The size of() operator returns the size of the operand and is the most common operator in C. This operator when used along with datatypes, returns the memory allocated of that datatype.

C Program to find the size of int, float, double and char :

int main()
    printf("Size of char: %ld byte\n",sizeof(char));
    printf("Size of int: %ld bytes\n",sizeof(int));
    printf("Size of float: %ld bytes\n",sizeof(float));
    printf("Size of double: %ld bytes", sizeof(double));
    return 0;

Output :

        Size of char: 1 byte
		Size of int: 4 bytes
		Size of float: 4 bytes
		Size of double: 8 bytes

Share your thoughts

Ask anything about this examples