English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Comprehensive Collection of C Programming Examples
In this example, you will learn how the long keyword works.
To understand this example, you should be familiar with the followingC Programming LanguageTopic:
#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; }
Output result
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 scheme, 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 is greater than that of int and double variables.
By the way, the sizeof operator returns size_t (unsigned integer type).
The size_t data type is used to represent the size of objects. The format specifier for size_t is %zu.
Note:The long keyword cannot be used for float and char types.