#include<iostream> //Header files
using namespace std;
int main() //main Function
{
double value1,value2,result; //Assign Variables
char ooperator; // Character
cout<<"Please enter first value\n"; //output
cin>>value1;//input
cout<<"Enter an operator (mathematical symbol e.g + / * -)\n";
cin>>ooperator;
cout<<"Please enter second value\n";
cin>>value2;
cout<<"the result is"<<"\n"<<"-------\n";
switch(ooperator) //switch case
{
case '*': //if i enter * it will give me the following result
{
result=value1*value2;
cout<<result;
break; //if the condition is satisfied it break the program and go to end
}
case '+': //if i enter + it will give me the following result
{
result=value1+value2;
cout<<result;
break;
}
case '/': //if i enter / it will give me the following result
{
result=value1/value2;
cout<<result;
break;
}
case '-': //if i enter - it will give me the following result
{
result=value1-value2;
cout<<result;
break;
}
}
return 0;
}
Bookmarks