0% found this document useful (0 votes)
18 views

Arithmetic

The document contains C++ code that takes in two numbers from the user and an operator, performs the operation on the numbers, and displays the result. It includes variables for the numbers, result, and operator, takes in user input, performs an if/else chain to handle the different operators, and prints the output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Arithmetic

The document contains C++ code that takes in two numbers from the user and an operator, performs the operation on the numbers, and displays the result. It includes variables for the numbers, result, and operator, takes in user input, performs an if/else chain to handle the different operators, and prints the output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Abdulaziz, Mohammad Nadjer L.

CCC101 - FfGg

#include<iostream>

using namespace std;

int main (){

const double pi = 3.1416;

int a, b;

int sum, difference, product, division, modulo;

char operation;

cout << " \"Hello World!\"";

cout << "\n";

cout << "Enter 2 numbers:\n";

cin >> a >> b;

cout << "Choose Addition (+), Subtraction (-), Product (*), Division (/), Modulo (%) :: ";

cin >> operation;

if (operation =='-')

cout << "Difference is : " << (a-b)<< endl;

else if (operation =='+')

cout << "Sum is : " << (a+b)<< endl;

if (operation =='*')

cout << "Product is : " << (a*b)<< endl;

}
else if (operation =='/')

cout << "Division is : " << (a/b)<< endl;

if (operation =='%')

cout << "Modulo is : " << (a%b)<< endl;

cout << "\n \n";

cout <<"End";

return 0;

You might also like