Determine and Display Sizes of Data Types

1. Input:
No explicit input is required as the code focuses on determining the sizes of predefined data types.

2. Variable Declaration:
Declare variables of different data types: intType (int), floatType (float), doubleType (double), and charType (char).

3. Size Calculation and Display:
Use the sizeof operator to calculate the size (in bytes) of each variable.
Print the size of each variable using the printf function, indicating the data type and size.

Code Examples

#1 Example Program to Find the Size of Variables

Code - C Programming

int main() {
    int intType;
    float floatType;
    double doubleType;
    char charType;

    // sizeof evaluates the size of a variable
    printf("Size of int: %zu bytes\n", sizeof(intType));
    printf("Size of float: %zu bytes\n", sizeof(floatType));
    printf("Size of double: %zu bytes\n", sizeof(doubleType));
    printf("Size of char: %zu byte\n", sizeof(charType));
    return 0;
Copy The Code & Try With Live Editor


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


C Programing Example to Find the Size of int, float, double and char-DevsEnv

Appending into a File in C Programming