View Single Post
  #5 (permalink)  
Old December 18th, 2006, 08:27 AM
Geo121 Geo121 is offline
Friend of Wrox
 
Join Date: Jan 2006
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Geo121
Default

Okay I'm a little lost in your question mastrgamr but I think you asked

how to keep the program from closing after you enter the right age?

Once the right age is entered where you typed your if statement

under good choice declare a variable as an int name it condition and give it a value of 1

create a while loop that runs while condition == 1

then inside of the loop give the user something to do

such as an input and if they enter x then it ends the loop

here is an example

int condition = 1;
char exitvar = 'a';
while (condition == 1)
{
     cout << "type x to leave\n";
     cin >> exitvar;
     if (exitvar == 'x')
     {
            condition = 0;
     }
     else
     {
            exitvar = 'a';
     }
}

~ Geo

~ Don't take life too seriously, you'll never get out alive!
Reply With Quote