Program to display a menu with option add, subtract, multiplication and divide.
#include<iostream.h> #include<conio.h> void main() { int choice; char ch='y'; int n1,n2; clrscr(); while(ch=='y') { cout<<"\n Enter the first number: "; cin>>n1; cout<<"\n Enter the second number: "; cin>>n2; cout<<"\n 1.Addition \n 2.Subtraction \n 3.Multiplication \n 4.Division \n"; cout<<"\n Enter the choice: "; cin>>choice;
switch(choice) { case 1: cout<<"\n Addition= "<<n1+n2; break; case 2: cout<<"\n Subtraction= "<<n1-n2; break; case 3: cout<<"\n Multiplication= "<<n1*n2; break; case 4: cout<<"\n Division= "<<n1/n2; break; default: cout<<"\n Invalid Choice"; break; } cout<<"\n Do u want to continue? (y/n) : "; cin>>ch; } getch(); }
No comments:
Post a Comment