Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int menu();
- void DoTaskMany(int);
- using namespace std;
- int main()
- {
- bool exit = false;
- for (;;)
- {
- int choice = menu();
- switch(choice)
- {
- case 1:
- DoTaskMany(1);
- break;
- case 2:
- DoTaskMany(2);
- break;
- case 3:
- DoTaskMany(3);
- break;
- case 4:
- DoTaskMany(4);
- break;
- case 5:
- continue; // redundant!
- break;
- case 6:
- exit=true;
- break;
- default:
- cout << "Please select again! " << endl;
- break;
- } // end switch
- if (exit == true)
- break;
- } // end forever
- return 0;
- } // end main()
- int menu()
- {
- int choice;
- cout << " **** Menu **** " << endl << endl;
- cout << "(1) 100 o's " << endl;
- cout << "(2) 100 to 200 by twos. " << endl;
- cout << "(3) 200 to 300 by twos. " << endl;
- cout << "(4) 300 to 400 by twos. " << endl;
- cout << "(5) Redisplay menu. " << endl;
- cout << "(6) Quit. " << endl << endl;
- cout << ": ";
- cin >> choice;
- return choice;
- }
- void DoTaskMany(int which)
- {
- switch (which)
- {
- case 1:
- {
- int i, j;
- for (i = 1; i<100; i+=2)
- {
- std::cout << i << " ";
- }
- std::cout << std::endl;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement