Skip to content

Instantly share code, notes, and snippets.

@fadhil-riyanto
Created November 23, 2020 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fadhil-riyanto/511999faa983d816931b309724f41579 to your computer and use it in GitHub Desktop.
Save fadhil-riyanto/511999faa983d816931b309724f41579 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main(){
float a, b, res;
char choice, ch;
do
{
cout<<"1.Addition\n";
cout<<"2.Subtraction\n";
cout<<"3.Multiplication\n";
cout<<"4.Division\n";
cout<<"5.Exit\n\n";
cout<<"Enter Your Choice : ";
cin>>choice;
switch(choice)
{
case '1' : cout<<"Enter two number : ";
cin>>a>>b;
res=a+b;
cout<<"Result = "<<res;
break;
case '2' : cout<<"Enter two number : ";
cin>>a>>b;
res=a-b;
cout<<"Result = "<<res;
break;
case '3' : cout<<"Enter two number : ";
cin>>a>>b;
res=a*b;
cout<<"Result = "<<res;
break;
case '4' : cout<<"Enter two number : ";
cin>>a>>b;
res=a/b;
cout<<"Result = "<<res;
break;
case '5' : exit(0);
break;
default : cout<<"Wrong Choice..!!";
break;
}
cout<<"\n------------------------------------\n";
}while(choice!=5 && choice!=getchar());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment