I was wondering how to use the Rand feature ( i think that is what it is called) to make an integer randomize from 1 to 10. ( im a beginner at this)
P.S If Someone could point me in the direction of a good starter book that would be awesome!
I was wondering how to use the Rand feature ( i think that is what it is called) to make an integer randomize from 1 to 10. ( im a beginner at this)
P.S If Someone could point me in the direction of a good starter book that would be awesome!
rand()%10 + 1
seed your random number generator:
Code:srand(time(NULL)); // do this once per run of the program
then you can do this:Originally posted by Lithorien
Code:rand()%10 + 1
vvv And here are some books vvv
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
And read the FAQ. (Or the tutorial?)
"If you tell the truth, you don't have to remember anything"
-Mark Twain
A C++ book i think is awesome is "C++ Programming: from problem analysis to program design" i borrowed the book from someone who is taking a CSCI class the book is pretty expensive though.