---
title: "Arithmetic Operations"
description: "C plus plus code for arithmetic operations"
url: "https://www.geekboots.com/cpp/calculation"
markdown_url: "https://www.geekboots.com/cpp/calculation/md"
category: "C++ Programming"
author: "Geekboots"
published: "2016-06-06"
updated: "2026-11-30T01:43:45.900Z"
tags: ["cpp", "c plus plus", "Arithmetic operations"]
---

# Arithmetic Operations (C++ Programming)

> C plus plus code for arithmetic operations

## Source Code

### Arithmetic-operations.cpp

```cpp
#include<iostream>

/* tells the compiler to use the std namespace */
using namespace std;

int main() {
	int a, b;
	cout << "Enter a value:\n";

	/* read number from console and store it in "a" */
	cin >> a;
	cout << "Enter another value:\n";

	/* read number from console and store it in "b" */
	cin >> b;

	/* print text and value of calculation on screen */
	cout << "Sum: " << a + b << "\n";
	cout << "Subtract: " << a - b << "\n";
	cout << "Multiplication: " << a * b << "\n";
	cout << "Division: " << a / b << "\n";
	cout << "Modulus: " << a % b << "\n";
	return 0;
}


/* Output */
/* Enter a value:
8

Enter another value:
2

Sum: 10
Subtract: 6
Multiplication: 16
Division: 4
Modulus: 0 */
```

## Related Code Examples

- [STL Min Max](https://www.geekboots.com/cpp/stl-min-max) ([Markdown](https://www.geekboots.com/cpp/stl-min-max/md))
- [Multimap](https://www.geekboots.com/cpp/multimap) ([Markdown](https://www.geekboots.com/cpp/multimap/md))
- [Map](https://www.geekboots.com/cpp/map) ([Markdown](https://www.geekboots.com/cpp/map/md))
- [Binary Tree](https://www.geekboots.com/cpp/binary-tree) ([Markdown](https://www.geekboots.com/cpp/binary-tree/md))
- [Double Ended Queue](https://www.geekboots.com/cpp/deque) ([Markdown](https://www.geekboots.com/cpp/deque/md))
- [Queue](https://www.geekboots.com/cpp/queue) ([Markdown](https://www.geekboots.com/cpp/queue/md))
- [Stack](https://www.geekboots.com/cpp/stack) ([Markdown](https://www.geekboots.com/cpp/stack/md))
- [Doubly Linked list](https://www.geekboots.com/cpp/doubly-linkedlist) ([Markdown](https://www.geekboots.com/cpp/doubly-linkedlist/md))

---
Source: [Geekboots](https://www.geekboots.com/cpp/calculation)
