I
Imrahil
Guest
Code:
#include <iostream.h>
int main(void)
{
int guess;
int number=50;
cout << "Guess the number\n";
cin >> guess;
if (guess > number)
cout << "Lower\n";
else if (guess < number)
cout << "Higher\n";
else
cout << "It's correct!\n";
while(guess != number )
{
cout << "Please guess again\n";
cin >> guess;
if (guess > number)
cout << "Lower\n";
else if (guess < number)
cout << "Higher\n";
else
cout << "You're correct!\n";
}
return 0;
}
Try this out for yourself. I kind of was fooling around to get this right and somehow if did! Could someone help me clean it up a bit? But just keep it to the basics, no Functions or anything else higher, just loops and anything lower.
I got this idea from the Clock Game on the Price Is Right. The variable number is the number that you're trying to guess. So assigning any value to that will give you the number you must guess.
Thanks!
Imrahil
(edit by onions - added code tags)