---
title: "Syntax and example of long"
subject: "Computer Programming"
chapter: 3
key: "semester_1/computer_programming:syntax-long"
source: https://www.bctengineer.com/q/semester_1/computer_programming/syntax-long
site: BCT Engineering
---

# Syntax and example of long

Computer Programming · Chapter 3: Introduction to ‘C’ programming

- Asked in: 2071 Chaitra, 1 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/syntax-long
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-3

## Question

Write 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.

## Answer

`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.

```c
#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):
```text
123456789 9876543210123 4000000000
sizeof(long) = 8
```

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is long in C?
   A. A type modifier giving a larger integer type
   B. A floating type
   C. A string type
   D. A loop
   Answer: A. long gives an integer at least 32 bits. (Key point: Meaning)

2. Which specifier prints a long long?
   A. %ld
   B. %lu
   C. %lld
   D. %d
   Answer: C. %lld is for long long, %ld for long, %lu for unsigned long. (Key point: Format specifier)

3. Which is valid syntax?
   A. long variable_name;
   B. variable_name long;
   C. long: variable_name;
   D. long() variable_name;
   Answer: A. The syntax is long variable_name; (or long int). (Key point: Syntax)
