w3resource logo
C Programming Exercises

C Exercises: Demonstrate the working of keyword long

C Variable Type : Exercise-18 with Solution

Write a C program to demonstrate the working of keyword long.

Sample Solution:

C Code:

#include<stdio.h>
int main()
{
    int a;
    long b;
    long long c;

    double e;
    long double f;
    printf("\n Demonstrate the working of keyword long \n");
    printf("------------------------------------------\n");

    printf(" The size of int = %ld bytes \n", sizeof(a));
    printf(" The size of long = %ld bytes\n", sizeof(b));
    printf(" The size of long long = %ld bytes\n", sizeof(c));

    printf(" The size of double = %ld bytes\n", sizeof(e));
    printf(" The size of long double = %ld bytes\n\n", sizeof(f));

    return 0;
}

Sample Output:

 Demonstrate the working of keyword long                                                                      
------------------------------------------                                                                    
 The size of int = 4 bytes                                                                                    
 The size of long = 8 bytes                                                                                   
 The size of long long = 8 bytes                                                                              
 The size of double = 8 bytes                                                                                 
 The size of long double = 16 bytes 

C Programming Code Editor:


#include<stdio.h>

int main()
{
    int a;
    long b;
    long long c;

    double e;
    long double f;
    printf("\n Demonstrate the working of keyword long \n");
    printf("------------------------------------------\n");

    printf(" The size of int = %ld bytes \n", sizeof(a));
    printf(" The size of long = %ld bytes\n", sizeof(b));
    printf(" The size of long long = %ld bytes\n", sizeof(c));

    printf(" The size of double = %ld bytes\n", sizeof(e));
    printf(" The size of long double = %ld bytes\n\n", sizeof(f));

    return 0;
}

Improve this sample solution and post your code through Disqus