Back To C++ Menu Driven Programs
//program to make a simple calculator using switch statement without using functions (example of menu driven program) #include
#include
void main() { int a,b; int choice; clrscr(); cout<<"\nenter a value for a "; cin>>a; cout<<"\nenter a value for b "; cin>>b; cout<<"\n 1. Add a and b "; cout<<"\n 2. Subtract a and b "; cout<<"\n 3. Multiply a and b "; cout<<"\n 4. Divide a by b "; cout<<"\nenter your choice (1,2,3,4)"; cin>>choice; switch(choice) { case 1: cout<<"\nsum of a and b is "<