Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can use a <code>do while</code> loop like this:</p> <pre><code>int main() { int choice; bool menu = true; do{ cout &lt;&lt;"Please select one of the following options: \n"; cout &lt;&lt; "1: Play\n" "2: Help\n" "3: Config\n" "4: Quit\n"; cout &lt;&lt; "Enter your selection (1, 2,3 or 4): "; cin &gt;&gt; choice; //***************************************************************************** // Switch menu to display the menu. //***************************************************************************** switch (choice) { case 1: cout &lt;&lt; "You have chosen play"; int missed = playgame('programming'); break; case 2: cout &lt;&lt; "You have chosen help\n"; cout &lt;&lt; "Here is a description of the game Hangman and how it is played:\nThe word to guess is represented by a row of dashes, giving the number of letters, numbers and category. If the guessing player suggests a letter or number which occurs in the word, the other player writes it in all its correct positions"; break; case 3: cout &lt;&lt; "You have chosen config"; break; case 4: cout &lt;&lt; "You have chosen Quit, Goodbye."; break; default: cout&lt;&lt; "Your selection must be between 1 and 4!\n"; } }while(choice!=4); getchar(); getchar(); cout &lt;&lt; "You missed " &lt;&lt; playGame("programming"); cout &lt;&lt; " times to guess the word programming." &lt;&lt; endl; </code></pre> <p>}</p> <p>I have added the do loop before you display your menu so that everytime the user chooses a choice, the user is displayed the menu again unless the user enters 4, in which case , the program comes out of the do while loop. You can call the function playgame() in case 1..I have edited my answer to include playgame();</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload