Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Newbie question
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 #include 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

so could someone help me?

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.
Tony

Posted: Fri Jun 13, 2003 5:04 pm   Post subject: (No subject)

i think rand() generates a random number between 0 and 1 You gotta multiply by a 100 then convert it to integer.

 code: num = (int)(rand()*100)

or something like that
Tony's programming blog. DWITE - a programming contest.
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
Catalyst

Posted: Fri Jun 13, 2003 8:59 pm   Post subject: (No subject)

asian is right is goes from 0 to RAND_MAX
Homer_simpson

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 =/
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!!
krishon

Posted: Sat Jun 14, 2003 7:51 pm   Post subject: (No subject)

ezz up on him, he's just beginning

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.
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
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 10 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: