Aamir Khan is suffering from short term memory loss and he has forgotten how to
add, subtract, multiply,modulo division and division. Write a C++ program to help Aamir t
perform the basic arithmetic operations.
INPUT & OUTPUT FORMAT:
Input consists of two integers. Output consist of integers
Share
Answer:
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
int sum=a+b;
int sub = a-b;
int div = a/b;
int mod= a%b;
int mul= a*b;
char op;
cin>>op;
if(op=='+')
cout<<sum;
else if(op=='-')
cout<<sub;
else if(op=='*')
cout<<mul;
else if(op=='/')
cout<<div;
else if(op=='%')
cout<<mod;
return 0;
}
Answer:
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
cout<<a-b<<endl;
cout<<a*b<<endl;
cout<<a%b<<endl;
cout<<a/b;
return 0;
}
Explanation: