September 30th, 2003, 04:36 PM
repeating a program
I was just wondering if there was a simple way of repeating my program... heres and exapmle...
int number = 5;
cout <<"choose a number between 1 and 50000"<<endl;
cout <<"inter your guess"<<endl;
if (guess == number)
cout << "WOW YOUR RIGHT!!!"<< endl;
else if (guess < number)
cout <<"guess higher!"<<endl;
cout <<"guess lower!"<<endl;
it just asks you to guess a number and if you guess it wrong the tells you what you need to do (higher or lower). How do i make it to were it tells you higher or lower, and then let you do it again without closeing?
September 30th, 2003, 04:41 PM
A while loop. (or a do-while).
// your existing code body here
} while( guess == number ) ;
September 30th, 2003, 04:53 PM
were exactly do i put it... before in the code
and were do i end it...
September 30th, 2003, 07:00 PM