How do you add an option to c++?

closed account (ETA4izwU)
I just started on a project on c++ and I was wondering if it is possible to add a select option (where the c++ program requires the user to select an option) . I couldn't find this anywere.
Simple example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main(){
   int choice(0);
   cout << "Hello human. Please select one of the following choices:\n"
      << "\t1) Say hi \n\t2) Say bye \n\t3) Explosion \n"
      << "Your choice: ";
   cin >> choice;
   switch(choice){
      case 1:
         cout << "Hello again." << endl;
         break;
      case 2:
         cout << "Goodbye." << endl;
         break;
      case 3:
         cout << "BWAAAAAGHHHH" << endl;
         break;
      default:
         break;
   }
   return 0;
}


I couldn't find this anywere.

Really?
Last edited on
closed account (ETA4izwU)
Im just a beginner. Lol
closed account (ETA4izwU)
Thanks!
Topic archived. No new replies allowed.