so i'm stuck in creating a do/while menu doing this.

menu option 1 - use the for loop

menu option 2 - use the while loop

menu option 3 - use the do/while loop

in each option, print the numbers from 1 to 10

I made my functions like this. Anyone know how to do this?
the code on the bottom is just a example the teacher show us for do/while

#include <iostream>                       // needed for cin/count
#include <cmath>                         // needed for math functions
using namespace std;

/****************************
*    prototypes    //declared function so main can find
*****************************/
void option01();

int main ()  // prototype to main
{
    char option;
    do
    {
    cout << "             WYZ Company     \n\n";
    cout << "          1 - for loop    \n\n";
    cout << "          2 - while loop    \n\n";
    cout << "          3 - do while loop    \n\n";
    cout << "          4 - stuff01    \n\n";
    cout << "          5 - stuff02    \n\n";
    cout << "          9 - exit    \n\n";
    cout << "enter desired processing option here: [ ]\b\b";

    cin >> option;

    switch(option)
    {
      case '1':   option01();
                break;
      case '2':   cout << "you entered option 2\n";
                break;      
      case '3':   cout << "you entered option 3\n";
                break;    
      case '4':   cout << "you entered option 4\n";
                break;    
      case '5':   cout << "you entered option 5\n";
                break;    
      case '9':   cout << "we'er otta here\n";
                break;       
      default:   cout << "wrong code dummy\n";              
    } // end switch
    }while(option != '9');
    system("pause");   
}   
void option01()
{
     cout << "you entered option 1\n";

Just embed the switch statement to activate the menu choice within a do/while loop as indicated in the instruction

do
{
   //display menu
   switch(choice)
   {
       case 1: 
           //use for loop
           break
       case 2:
          //use while loop
          break
       case 3:
          //use do/while loop
          break
       case 6:
          //exit
       default
         //output information to user
     }//end switch
   }while (choice != 6)

I did it like this but it seems not to be working. anyone know the problem

void option01();

int main ()  // prototype to main
{
    char option;
    do
    {
    cout << "             WYZ Company     \n\n";
    cout << "          1 - for loop    \n\n";
    cout << "          2 - while loop    \n\n";
    cout << "          3 - do while loop    \n\n";
    cout << "          4 - stuff01    \n\n";
    cout << "          5 - stuff02    \n\n";
    cout << "          9 - exit    \n\n";
    cout << "enter desired processing option here: [ ]\b\b";

    cin >> option;

    do
{
   //display menu
   switch(option)
   {
       case 1: cout << "you entered option 1\n";
           //use for loop
           break;
       case 2: cout << "you entered option 2\n";
          //use while loop
          break;
       case 3: cout << "you entered option 3\n";
          //use do/while loop
          break;
       case 6: cout << "you entered option 9\n";
          //exit
       default: cout << "wrong code dummy\n";
         //output information to user
     } //end switch
   }while (choice != 6)
    system("pause");   
}   
void option01()
{
     cout << "you entered option 1\n";
}

When you say something isn't working, it suggests that the code even compiles, which it doesn't. Does this work the way you expect?

#include <iostream>

using namespace std;

int main()
{
  int option;
  do
  {
    cout << "             WYZ Company\n\n";
    cout << "          1 - for loop\n\n";
    cout << "          2 - while loop\n\n";
    cout << "          3 - do while loop\n\n";
    cout << "          4 - stuff01\n\n";
    cout << "          5 - stuff02\n\n";
    cout << "          6 - exit\n\n";
    cout << "enter desired processing option here: [ ]\b\b";

    cin >> option;

    //display menu
    switch(option)
    {
    case 1: cout << "you entered option 1\n";
      break;
    case 2: cout << "you entered option 2\n";
      //use while loop
      break;
    case 3: cout << "you entered option 3\n";
      //use do/while loop
      break;
    case 6: cout << "you entered option 6\n";
      //exit
      break;
    default: cout << "wrong code dummy\n";
      //output information to user
      break;
    } //end switch
  }while (option != 6);
  system("pause");   
}

Try using

int option;

I need help to make
1 2 3
2 4 6
3 6 9
using for up to....
please help

Member Avatar for mISHOOO

I need help to make
1 2 3
2 4 6
3 6 9
using for up to....
please help

for (i=1; i<=3; i++) {
for (j=1; j<=3; j++) cout<<j*i<<" ";
cout<<endl;
}

i dont know when we use for loop, while , and do while , is there specific sitution when we use these.n our teacher learn us for this output a b c d e f g h i j k l m n o p q r s t u v w x y z.

for(int i=65;i<=90;i++)
cout << static_cast <char >(I)<<"  ";

here my qustiion is why we use this for(int i=65;i<=90;i++)statment for a b c d e................ make me clear plz

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.