This code displays the amount of memory (in bytes) that is set aside for various types of data in C. To find out how big an int, float, double, or char is, you can use the sizeof() function. The answer is then shown in bytes by the printf() function. It is important to know that different types of data need different amounts of memory when writing programs that work well.

#include <stdio.h>

int main() {
    printf("Size of int: %lu bytes\n", sizeof(int));  // Display size of an int
    printf("Size of float: %lu bytes\n", sizeof(float));  // Display size of a float
    printf("Size of double: %lu bytes\n", sizeof(double));  // Display size of a double
    printf("Size of char: %lu bytes\n", sizeof(char));  // Display size of a char
    return 0;
}

One thought on “Program to Find the Size of Different Data Types”

Leave a Reply

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

Verified by MonsterInsights