forked from Shubhamlmp/Programming-Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
23_Mathematical_Expression.cpp
26 lines (23 loc) · 1.11 KB
/
23_Mathematical_Expression.cpp
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
#include<bits/stdc++.h>
using namespace std;
int main() {
int a,b,c;
char s,q;
cin>>a>>s>>b>>q>>c; //accepting all the values from user
if(s=='+' && a+b==c){ //condition for checking if the symbol is + and answer is correct or not
cout<<"Yes"<<endl;
}
else if(s=='+') //condition for checking if the symbol is + and ans is false then printing the correct value
cout<<a+b<<endl;
if(s=='-' && a-b==c){ //condition for checking if the symbol is - and answer is correct or not
cout<<"Yes"<<endl;
}
else if(s=='-') //condition for checking if the symbol is - and ans is false then printing the correct value
cout<<a-b<<endl;
if(s=='*' && a*b==c){ //condition for checking if the symbol is * and answer is correct or not
cout<<"Yes"<<endl;
}
else if(s=='*')
cout<<a*b<<endl; //condition for checking if the symbol is * and ans is false then printing the correct value
return 0;
}