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

June 5, 2021

This program finds the size of data types such as char, int, float, double.

Example: Program to find the size of data types in C

In this program, we are using the sizeof() operator to find the size of data types. When the sizeof is used with the primitive data types such as int, float, double and char then it returns the amount of the memory allocated to them.

#include<stdio.h>
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

admin