Get Website Learn Coding Tech Story

C++ Programming Examples

#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