Home / Programs / sizeof() operator, Returns the size of a variable.
Programming Example

sizeof() operator, Returns the size of a variable.

👁 1,157 Views
💻 Practical Program
📘 Step by Step Learning
Study this program carefully to understand the logic, output, and explanation in a structured way.

Program Code

#include <stdio.h>
int main()
{
    int a, e[10];
    float b;
    double c;
    char d;
    printf("Size of int=%lu bytes\n",sizeof(a));
    printf("Size of float=%lu bytes\n",sizeof(b));
    printf("Size of double=%lu bytes\n",sizeof(c));
    printf("Size of char=%lu byte\n",sizeof(d));
    printf("Size of integer type array having 10 elements = %lu bytes\n", sizeof(e));
    return 0;
}

Output

Size of int=4 bytes
Size of float=4 bytes
Size of double=8 bytes
Size of char=1 byte
Size of integer type array having 10 elements = 40 bytes
Press any key to continue . . .

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.