Advertisement
joloos

main menu template

Dec 21st, 2023 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | Source Code | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void name1(){}
  5. void name2(){}
  6. void name3(){}
  7.  
  8.  
  9. int main(){
  10.      //Main Menu
  11.     while(true){
  12.     int option;
  13.     cout<<"LOOP SIMULATION MENU";
  14.     cout<<endl<<"[1] name1";
  15.     cout<<endl<<"[2] name2";
  16.     cout<<endl<<"[3] name3";
  17.     cout<<endl<<"Option: ";
  18.     cin>>option;
  19.     cout<<option;
  20.    
  21. switch(option){ //Main Menu Backend
  22. case 1:
  23. name1();
  24. system("cls");
  25. break;
  26.  
  27. case 2:
  28. name2();
  29. system("cls");
  30. break;
  31.  
  32. case 3:
  33. name3();
  34. system("cls");
  35. break;
  36.  
  37. default: // When invalid option selected. Continues the while loop which returns you to the menu screen.
  38. system("cls");
  39. cout<<"\nInput a correct choice\n\n";
  40. continue;
  41.     }
  42. break;
  43.         }
  44.     }
  45.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement