Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- cout<<"10+20"<<calc(10,20,+);
- cout<<"10*20"<<calc(10,20,*);
- cout<<"10-20"<<calc(10,20,-);
- cout<<"10/20"<<calc(10,20,/);
- }
- int calc (int a, int b, char c)
- {
- int total=0;
- if(c=='+'){
- total = a+b;
- }else if(c=='*'){
- total = a*b;
- }else if(c=='-'){
- total = a-b;
- }else if(c=='/'){
- total = a/b;
- }
- return total;
- }
Add Comment
Please, Sign In to add comment