Author |
Message |
AsianSensation
|
Posted: Fri Jun 13, 2003 3:56 pm Post subject: Newbie question |
|
|
I am just startin to learn C++, and I am using visual studio 6.0. I've been reading some tutorial off the net, and I tried to make a number guesser thingie, except it's not working, and I don't know whats wrong with it. code: | #include <stdlib.h>
#include <iostream.h>
int main ()
{
int num, guess;
num=rand() % 100;
int i=0;
while (i<10);
{
cin >> guess;
if (guess>num)
{
cout<< "High";
i++;
}
else if (guess<num)
{
cout<< "Low";
i++;
}
else
{
cout<< "Yay!, You got it!";
return 0;
}
}
return 0;
} |
so could someone help me? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Fri Jun 13, 2003 5:02 pm Post subject: (No subject) |
|
|
nvm, I fixed it, but I still don't know what was wrong with the other one. |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
|
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Fri Jun 13, 2003 5:11 pm Post subject: (No subject) |
|
|
I thought rand() gave u a number between 0 and Rand_Max, but that wasn't the problem, the problem is when I run it, I cannot even input. and I don't know y ![Confused Confused](http://compsci.ca/v3/images/smiles/icon_confused.gif) |
|
|
|
|
![](images/spacer.gif) |
Catalyst
![](http://catalyze.mine.nu/jack_of_spades+100.jpg)
|
Posted: Fri Jun 13, 2003 8:59 pm Post subject: (No subject) |
|
|
asian is right is goes from 0 to RAND_MAX |
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Fri Jun 13, 2003 9:01 pm Post subject: (No subject) |
|
|
when i tried the program... i couldn't even input anything for some reason =/ |
|
|
|
|
![](images/spacer.gif) |
SilverSprite
|
Posted: Sat Jun 14, 2003 1:10 pm Post subject: (No subject) |
|
|
Wow no offense to you Asian, but that program is real sloppy! Soo many things wrong with it!! |
|
|
|
|
![](images/spacer.gif) |
krishon
|
Posted: Sat Jun 14, 2003 7:51 pm Post subject: (No subject) |
|
|
ezz up on him, he's just beginning |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
SilverSprite
|
Posted: Sat Jun 14, 2003 10:08 pm Post subject: (No subject) |
|
|
Lol you don't understand... I've showed him a few things, and he's had experience with turing.. tut tut tut asian i'm disappointed. |
|
|
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Sat Jun 14, 2003 10:24 pm Post subject: (No subject) |
|
|
yeah, i know, i should be ashamed of myself, after all the stuff SilverSprite taught me.....*sob sob ![Crying or Very sad Crying or Very sad](http://compsci.ca/v3/images/smiles/icon_cry.gif) |
|
|
|
|
![](images/spacer.gif) |
|