Created
September 30, 2018 18:17
-
-
Save WIttyJudge/af67bd27096496e4203849508db5a147 to your computer and use it in GitHub Desktop.
Features of this programm: 1) Division by zero isn't possible.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
float fr, sc, result; | |
char action1; | |
cout << " Enter the first number: "; | |
cin >> fr; | |
cin.ignore(); | |
cout << "\n" << " To choose one of the action. It can be: \n"; | |
cout << " + (addition), - (subtraction), / (division) or * (multiplication).\n" << " Your choose: "; | |
cin >> action1; | |
cout << "\n" << " Enter the second number: "; | |
cin >> sc; | |
cin.ignore(); | |
switch (action1) | |
{ | |
case '+': | |
{ | |
result = fr + sc; | |
cout << "\n" << " Result: " << result << endl<<endl; | |
break; | |
} | |
case '-': | |
{ | |
result = fr - sc; | |
cout << "\n" << " Result: " << result << endl<<endl; | |
break; | |
} | |
case '*': | |
{ | |
result = fr * sc; | |
cout << "\n" << " Result: " << result << endl<<endl; | |
break; | |
} | |
case '/': | |
{ | |
result = fr / sc; | |
if (sc == 0) | |
cout << "\n" << " Error. Devision by zero isn't possible. " << endl<<endl; | |
else | |
cout << "\n" << " Result: " << result << endl<<endl; | |
break; | |
} | |
default: | |
{ | |
cout << "\n" << " Error. Given character wasn't found" << endl<<endl; | |
} | |
} | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment