3li773
08-26-2003, 11:48 AM
Hi I was making a simple number guess game this morning and I cant get the loop to work at all can someone tell me what is wrong
(And no laughing because a newb can't get a loop to work)
#define MAX_RANGE 100
#define NUM 89
#include <iostream.h>
int main()
{
int counter=0;
int cmd;
cout<<"Guess a number between 1-"<<MAX_RANGE<<endl;
while (cmd!=NUM);
{
scanf("%i",cmd);
counter++;
if (cmd==NUM)
{
cout<<"Good job"<<endl;
cout<<"It took you"<< counter <<"tries"<<endl;
cin.get();
system("EXIT");
}
else if (cmd<NUM)
{
cout<<"Guess higher"<<endl;
}
else if (cmd>NUM)
{
cout<<"Guess lower"<<endl;
}
return 0;
}
}
any help would be good
(And no laughing because a newb can't get a loop to work)
#define MAX_RANGE 100
#define NUM 89
#include <iostream.h>
int main()
{
int counter=0;
int cmd;
cout<<"Guess a number between 1-"<<MAX_RANGE<<endl;
while (cmd!=NUM);
{
scanf("%i",cmd);
counter++;
if (cmd==NUM)
{
cout<<"Good job"<<endl;
cout<<"It took you"<< counter <<"tries"<<endl;
cin.get();
system("EXIT");
}
else if (cmd<NUM)
{
cout<<"Guess higher"<<endl;
}
else if (cmd>NUM)
{
cout<<"Guess lower"<<endl;
}
return 0;
}
}
any help would be good