---
title: "3.2 Subtraction Operator (-)"
description: "The subtraction operator (`-`) subtracts the value of the right operand from the value of the left operand and returns the difference. It is supported for all built-in numeric data types, including integers and floating-point values. When both operands are…"
url: "https://edcret.in/docs/cpp-programming/operators-cplusplus/3-2-subtraction-operator/"
updated: "2026-07-28"
category: C++ Programming / Operators
---

# 3.2 Subtraction Operator (-)

The subtraction operator (`-`) subtracts the value of the right operand from the value of the left operand and returns the difference. It is supported for all built-in numeric data types, including integers and floating-point values.

When both operands are integers, the result is an integer. If one or both operands are floating-point values, the operands undergo the usual arithmetic conversions, and the result is a floating-point value.

## Source Code

```
#include <iostream>

int main()
{
    int num1 = 50;
    int num2 = 18;

    int difference = num1 - num2;

    std::cout << "First Number : " << num1 << '\n';
    std::cout << "Second Number: " << num2 << '\n';
    std::cout << "Difference   : " << difference << '\n';

    return 0;
}
```

## Output

```
First Number : 50
Second Number: 18
Difference   : 32
```

## Explanation

- The subtraction operator (`-`) subtracts the value of the right operand from the value of the left operand.
- `num1 - num2` evaluates to the difference between the two integer values.
- The resulting value is assigned to the variable `difference`.
- Both operands are of type `int`, so the result is also an integer.
- The value stored in `difference` is displayed using `std::cout`.
- The subtraction operator can also be used with floating-point data types.
- `return 0;` terminates the program successfully.
