-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcalc.cpp
More file actions
53 lines (44 loc) · 1.05 KB
/
Copy pathcalc.cpp
File metadata and controls
53 lines (44 loc) · 1.05 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
52
53
#include<iostream>
using namespace std;
int main()
{
int n1,n2;
char c,k;
cout<<"HEY THERE! Welcome to my calculator!\n";
check:
cout<<"ENTER THE FIRST NUMBER YOU WANT TO DO CALCULATE\n";
cin>>n1;
cout<<"ENTER THE SECOND NUMBER YOU WANT TO DO CALCULATE\n";
cin>>n2;
cout<<"Enter any of the following operator to perform operation on the numbers: \n";
cout<<"+,-,*,/,% \n ";
cin>>c;
if(c=='+')
{
cout<<n1<<"+"<<n2<<" = "<<n1+n2;
}
else if(c=='-')
{
cout<<n1<<"-"<<n2<<" = "<<n1-n2;
}
else if(c=='*')
{
cout<<n1<<"*"<<n2<<" = "<<n1*n2;
}
else if(c=='/')
{
cout<<n1<<"/"<<n2<<" = "<<n1/n2;
}
else if(c=='%')
{
cout<<n1<<"%"<<n2<<" = "<<n1%n2;
}
else cout<<"ENTER VALID OPERAND";
cout<<"DO YOU WANT TO ENTER THE NUMBERS AGAIN? IF YES THEN ENTER Y OTHERWISE ENTER N";
cin>>k;
if(k=='Y')
{
goto check;
}
return 0;
}