Title : = Write a C++ program create a calculator for an arithmetic operator (+, -, *, /). The program should take two operands from user and performs the operation on those two operands depending upon the operator entered by user.
/*Title : = Write a C++ program create a calculator for an arithmetic operator (+, -, *, /). The program should take two operands from user and performs the operation on those two operands depending upon the operator entered by user.*/
#include<iostream>
using namespace std;
int main()
{
int a,c,b;
char ch;
cin>>a;
cin>>ch;
cin>>b;
switch(ch)
{
case '+': //Addition
c=a+b;
cout<<c;
break;
case '-': //Subtraction
c=a-b;
cout<<c;
break;
case '*': //Multiplication
c=a*b;
cout<<c;
break;
case '/': //Division
c=a/b;
cout<<c;
break;
}
}
#include<iostream>
using namespace std;
int main()
{
int a,c,b;
char ch;
cin>>a;
cin>>ch;
cin>>b;
switch(ch)
{
case '+': //Addition
c=a+b;
cout<<c;
break;
case '-': //Subtraction
c=a-b;
cout<<c;
break;
case '*': //Multiplication
c=a*b;
cout<<c;
break;
case '/': //Division
c=a/b;
cout<<c;
break;
}
}
Comments
Post a Comment