C Program to Demonstrate the Working of Keyword long

In this example, you will learn to demonstrate the working of the long keyword.

To understand this example, you should have the knowledge of the following C programming topics:

Program Using the long keyword

#include <stdio.h>
int main() {
    int a;
    long b;   // equivalent to long int b;
    long long c;  // equivalent to long long int c;
    double e;
    long double f;

    printf("Size of int = %ld bytes \n", sizeof(a));
    printf("Size of long int = %ld bytes\n", sizeof(b));
    printf("Size of long long int = %ld bytes\n", sizeof(c));
    printf("Size of double = %ld bytes\n", sizeof(e));
    printf("Size of long double = %ld bytes\n", sizeof(f));
    
    return 0;
}

Output

Size of int = 4 bytes 
Size of long int = 8 bytes
Size of long long int = 8 bytes
Size of double = 8 bytes
Size of long double = 16 bytes

In this program, the sizeof operator is used to find the size of int, long, long long, double and long double variables.

As you can see, the size of long int and long double variables are larger than int and double variables, respectively.

Note: The long keyword cannot be used with float and char type variables.