- 2071 Chaitra · 1 mark
Syntax and example of long
Short answer
long declares a larger integer type (at least 32 bits). Syntax: long variable_name; or long int variable_name; Example: long population = 123456789L; printf("%ld", population); outputs 123456789, and sizeof(long) typically returns 8 on 64-bit Linux.
Write syntax and example of long.
long is a type modifier that gives an integer type larger than a normal int (at least 32 bits; 64 bits on most 64-bit Linux systems).
Syntax: long variable_name; (also long int, unsigned long, long long)
Format specifiers: %ld for long, %lld for long long, %lu for unsigned long.
#include <stdio.h>
int main(void)
{
long population = 123456789L;
long long big = 9876543210123LL;
unsigned long u = 4000000000UL;
printf("%ld %lld %lu\n", population, big, u);
printf("sizeof(long) = %d\n", (int)sizeof(long));
return 0;
}
Output (64-bit Linux; on Windows sizeof(long) is 4):
123456789 9876543210123 4000000000
sizeof(long) = 8
✓ Answer checked by Claude Opus 5.5 (high effort)