#include <iostream>
using namespace std;

int main()
{
    //delcare varialbe
    
    char selection;
    //declare function
    void counting_loop();
    void impossible();
    void missing_item();
    void odd_even();
    void poem();
    void pause_m(void);
    
    do
    {
          
          cout << " Welcome to the Fun Program" << endl;
          cout << " Select from the menu " << endl ; 
       
          cout << "A gets Counting loop. " << endl;
          cout << "B gets Impossible."<< endl;
          cout << "C gets Missing Item."<< endl;
          cout << "D gets Odd or Even." << endl ;
          cout << "E gets Poem." << endl;
     
          cout << " Enter the letter of your choice. " << endl;
          cout << " Then hit the enter key. " << endl;
        
          cout << " Your choice : --> " ;
          cin >> selection ;
          
          // switch command 
           switch (selection)
          {
                 case 'a':
                 case 'A': counting_loop(); // call function
                 break;
                 case 'b':
                 case 'B': impossible();// call function
                 break;
                 case 'c':
                 case 'C': missing_item();
                 break;
                 case 'd':
                 case 'D' : odd_even();
                 break;
                 case 'e':
                 case 'E': poem();
           }// end switch
           
    } while (selection!='Q'&&selection!='q');
    
}
    // function definition        
    
    //couting_loop
    void counting_loop()
    {
    for (int x=0 ; x< 5; x++)
    {
    cout << "Are we having fun ?" << endl ;
     pause_m();
    }
    }// end for
    // call function pause
    //---------------------------------------------//
    //fucntion pause
   void pause_m(void)
  {
  cout << "\n\n";
  system("PAUSE");
  cout << "\n\n";
  return;
  }
    //------------------------------------------//
    //clear function
    void clear_m(void)
    {
    system("CLS");
    return;
    }
   //---------------------------------------//
   void impossible()
   {
        cout << " The repeat until loop is impossible in C++." << endl;
        pause_m();
   }
   void missing_item()
   {      
     cout << "This program is missing only the while loop." << endl ;
     pause_m();
   }
   void odd_even()
   {
        int userinput;
        cout << " Enter an integer : " << endl;
        cin >> userinput;
        if ( userinput % 2 = 0) 
        {
             cout << " Your number was odd. " << endl ;
        }
         else
         {
             cout << " Your number was even. " << endl ; 
         }
        pause_m();
   }
             
   void poem()
   {
        cout <<"Feelings that once were hidden" <<endl;
        cout <<"Are now expressed to you." << endl;
        cout <<"Days that once were stormy" << endl;
        cout <<"Are now the brightest blue." << endl;
        pause_m();
        
   }

it kept saying that the fucntion pause is undeclare ? dont' know why ? anyhelps are appirciated

Recommended Answers

All 3 Replies

If you use "system", you should import cstdlib, because that's the library "system" is from.

But don't use system ("PAUSE") anyway. Use cin.get() once or twice instead.

http://www.gidnetwork.com/b-61.html

i don't know what you means., .... i incpluded the using namespace std;
other program runs well
i have to use that beacuase that's the requirement

i don't know what you means., .... i incpluded the using namespace std;
other program runs well
i have to use that beacuase that's the requirement

http://www.cplusplus.com/reference/clibrary/cstdlib/system/

"system" is in cstdlib, not iostream.

But you're right. That's not the problem. You need to proofread your posts. The error isn't that "PAUSE" can't be found, it's that "pause_m" can't be found, so I saw "system" and saw that you hadn't included the cstdlib library, so I figured that could be the problem.

Look at lines 9 - 15. You should move them to before line 4.

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.