---
title: 1.9 Type Modifiers
description: "Type modifiers change the size or range of fundamental integer data types. C++ provides the modifiers `signed`, `unsigned`, `short`, and `long` to represent different ranges of integer values. This example demonstrates the declaration and use of variables with different type…"
url: "https://edcret.in/docs/cpp-programming/basic-refreshers-cplusplus/1-9-type-modifiers/"
updated: "2026-07-28"
category: C++ Programming / Basic Refreshers
---

# 1.9 Type Modifiers

Type modifiers change the size or range of fundamental integer data types. C++ provides the modifiers `signed`, `unsigned`, `short`, and `long` to represent different ranges of integer values.

This example demonstrates the declaration and use of variables with different type modifiers.

## Source Code

```
#include <iostream>

int main()
{
    short temperature = -10;
    unsigned int population = 50000;
    long distance = 1500000L;
    long long stars = 20000000000LL;

    std::cout << "Temperature: " << temperature << '\n';
    std::cout << "Population: " << population << '\n';
    std::cout << "Distance: " << distance << '\n';
    std::cout << "Stars: " << stars << '\n';

    return 0;
}
```

## Output

```
Temperature: -10
Population: 50000
Distance: 1500000
Stars: 20000000000
```

## Explanation

- `short` stores integer values using fewer bits than `int` on most implementations, making it suitable for smaller integer ranges.
- `unsigned int` stores only non-negative integer values, allowing a larger positive range than a signed `int` of the same size.
- `long` is intended for storing larger integer values than `int`. Its size is implementation-defined.
- `long long` provides an integer type capable of storing larger values than `long`.
- The suffix `L` specifies that the literal is of type `long`.
- The suffix `LL` specifies that the literal is of type `long long`.
- The exact size of `short`, `int`, `long`, and `long long` depends on the compiler and target platform. C++ specifies their minimum ranges rather than fixed sizes.
- Each `std::cout` statement prints the value stored in the corresponding variable.
- `return 0;` terminates the program successfully.
