Sat Oct 26 2019

Arithmetic Operations

C++ Programming1284 views

File Name: Arithmetic-operations.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 */

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.