-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2.cpp
More file actions
51 lines (41 loc) · 1.56 KB
/
task2.cpp
File metadata and controls
51 lines (41 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// TASK 2
// SIMPLE CALCULATOR
/*statement-->Develop a calculator program that performs basic arithmetic
operations such as addition, subtraction, multiplication, and
division. Allow the user to input two numbers and choose an
operation to perform.*/
#include <iostream>
using namespace std;
int main()
{ // main function
int num1, num2; // decleration of two input
char operation; // decleration of arithmetic operation
cout << "enter a first value--> "; // first number input from user
cin >> num1;
cout << " enter the arithmetic operation to performs the value--> ";
// arithmetic operation-->+,-,*,/,%
cin >> operation;
cout << "enter a second value--> "; // second number input from user
cin >> num2;
switch (operation)
{
case '+':
cout << "Result--> " << num1 + num2 << endl; //addition operation
break;
case '-':
cout << "result--> " << num1 - num2 << endl; //subtraction operation
break;
case '*':
cout << "result--> " << num1 * num2 << endl; //multiplication operation
break;
case '/':
cout << "result--> " << num1 / num2 << endl; //division operation
break;
case '%':
cout << "result--> " << num1 % num2 << endl; //find reminder operation
break;
default:
cout << "invalide operation!,please enter valid arithmetic operation !";
break;
}
}