C Program to Demonstrate the Working of Keyword long | Program Code C SoftwareTechIT

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:

·         C Data Types

·         C Variables, Constants and Literals

·         C Input Output (I/O)



#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 = %zu bytes \n", sizeof(a));
    printf("Size of long int = %zu bytes\n", sizeof(b));
    printf("Size of long long int = %zu bytes\n", sizeof(c));
    printf("Size of double = %zu bytes\n", sizeof(e));
    printf("Size of long double = %zu bytes\n", sizeof(f));
    
    return 0;
}

Program Using the long keyword

 

In this program, the sizeof operator is used to find the size of intlonglong longdouble 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.

By the way, the sizeof operator returns size_t (unsigned integral type).

The size_t data type is used to represent the size of an object. The format specifier used for size_t is %zu.

 

Labels : #c ,#code ,

Post a Comment