C Program to find the size of primitive datatypes

Problem

Write a program in C to find and display the size of the primitive datatypes likes int , float , double and char using the sizeof function.

How to find the size of primitive datatypes in C?

#include <stdio.h>
int main()
{
    // AC- using sizeof function to get the size of the primitive datatypes.
    int intValue;
    printf("Size of int: %ld bytes\n",sizeof(intValue));
    float floatValue;
    printf("Size of float: %ld bytes\n",sizeof(floatValue));
    double doubleValue;
    printf("Size of double: %ld bytes\n",sizeof(doubleValue));
    char charType;
    printf("Size of char: %ld byte\n",sizeof(charType));
    return 0;
}

Output

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

%d