#include <iostream>
using namespace std;
int main()
{
char operation;
int num1 , num2;
cout << "Enter operator either + or - or * or /: "<<endl;
cin >> operation;
cout << "Enter First operand: "<<endl;
cin >> num1;
cout << "Enter Second operand: "<<endl;
cin >> num2;
switch(operation) {
case '+' :
cout<<"The Answer Is: " << num1+num2<<endl;
break;
case '-' :
cout<<"The Answer Is: " << num1-num2<<endl;
break;
case '*' :
cout<<"The Answer Is: " << num1*num2<<endl;
break;
case '/' :
cout<<"The Answer Is: "<< num1/num2<<endl;
break;
default:
/* If operater is other then +, -, * or /, error message is shown */
cout << "Error! operator is not correct";
break;
}
cout<< "******************" << "\n"
<< "Regards Talha Ch"<< "\n"
<< "******************" << "\n"
<< endl;
return 0;
}
using namespace std;
int main()
{
char operation;
int num1 , num2;
cout << "Enter operator either + or - or * or /: "<<endl;
cin >> operation;
cout << "Enter First operand: "<<endl;
cin >> num1;
cout << "Enter Second operand: "<<endl;
cin >> num2;
switch(operation) {
case '+' :
cout<<"The Answer Is: " << num1+num2<<endl;
break;
case '-' :
cout<<"The Answer Is: " << num1-num2<<endl;
break;
case '*' :
cout<<"The Answer Is: " << num1*num2<<endl;
break;
case '/' :
cout<<"The Answer Is: "<< num1/num2<<endl;
break;
default:
/* If operater is other then +, -, * or /, error message is shown */
cout << "Error! operator is not correct";
break;
}
cout<< "******************" << "\n"
<< "Regards Talha Ch"<< "\n"
<< "******************" << "\n"
<< endl;
return 0;
}
0 comments:
Post a Comment