0

How to make any menu driven program in C

any menu driven program using switch case

25th Jan 2017, 6:24 AM
Jagat Raj
Jagat Raj - avatar
2 odpowiedzi
+ 6
#include <iostream> using namespace std; void menu(); int main() { int user_choice; menu(); cout << "Please input your choice of selection."; cin >> user_choice; switch (user_choice) { case 1: cout << "🍪🍪🍪"; break; case 2: cout << "🍪🍪🍪🍪🍪🍪🍪"; break; case 3: cout << "🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪"; break; default: cout << "No cookies for you."; } return 0; } void menu() { cout << "Welcome to the cookie program!" << endl; cout << " 1) Cookies " << endl; cout << " 2) More cookies!" << endl; cout << " 3) Too many cookies!" << endl; }
25th Jan 2017, 6:31 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
lol
25th Jan 2017, 6:33 AM
Kawaii
Kawaii - avatar