Created
August 16, 2017 19:41
-
-
Save urmil0071/e871f42e465007f532b862762e288c5a to your computer and use it in GitHub Desktop.
simple c++ calculator with Switch statements
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; | |
void main() | |
{ | |
int a,b; | |
char c; | |
cout << "enter the two numbers to calculate" << endl; cin>>a>>b; | |
cout << " Press the desired operator , + for addition, - for substraction, * for multiplication, / for division " << endl; cin>>c; | |
switch (c) | |
{ | |
case '+' : | |
{cout << "the addition result between the two are == " << a+b << endl;};break; | |
case '-' : | |
{cout << "the subtraction result between the two are == " << a-b << endl;};break; | |
case '*' : | |
{cout << "the multiplication result between the two are == " << a*b << endl;};break; | |
case '/' : | |
{cout << "the division result between the two are == " << a/b << endl;};break; | |
default : cout << "invalid input, thats not a mathematical operator" << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment