Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Latest Posts

C Program to Demonstrate the Working of Keyword long

Keyword long is used for altering the size of data type. For example: the size of int is either 2 bytes or 4 bytes but, when long keyword is used, the size of long int will be either 4 bytes or 8 bytes. Also, you can use long long int. The size of long long int is generally 8 bytes. This program will demonstrate the size of keyword long for my system. It may be different in your system.

Source Code


#include <stdio.h>
int main(){
    int a;
    long int b;                /* int is optional. */
    long long int c;            /* int is optional. */
    printf("Size of int = %d bytes\n",sizeof(a));
    printf("Size of long int = %ld bytes\n",sizeof(b));
    printf("Size of long long int = %ld bytes",sizeof(c));
    return 0;
}
Output
Size of int = 4 bytes
Size of long int = 4 bytes
Size of long long int = 8 bytes
In this program, the sizeof operator is used for finding the size of intlong int and long long int.
Thus, int and long int for my system can hold values from -231 to 231-1. If I have to work on data outside this range, I have to use long long int, which can hold values from -263 to 263-1 .
Similarly, the long keyword can be used double and floats types.

Click Here For More example in c introduction chapter

Go Back on Home Chapter By Clicking below Button :)
If above button is not working then copy the below link and paste in your address bar.

http://www.mastercaptainit.com/p/c-programming-tutorial.html

No comments:

Post a Comment

Master Captain IT Designed by Master Captain It Team. Copyright © 2014

.
Theme images by Bim. Powered by Blogger.