I understand how to generate random numbers. How do I make the number keep changing throughout the program or when I tell it to?
How do you make random numbers with a range between lets say 10 and 20?
I need help here
to.
I understand how to generate random numbers. How do I make the number keep changing throughout the program or when I tell it to?
How do you make random numbers with a range between lets say 10 and 20?
I need help here
to.
My computer is awesome.
check this.
- "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
How can I accomplish that without the users input? In another post someone said that I can assign random numbers new values throughout the program how? I still don't know what to do in my other post. It seems that people usually stop posting and I have a lot of unaswered questions.
My computer is awesome.
The FAQ is your friend, sir. But sheesh, I'll tell you a nice, easy way.
Also honey...you don't always have to use the two parameters for main()...I notice you use them all the time, even when you don't even refer to them at all in your program.Code:int min, max; //We have a minimum value, and a maximum min=100; max=200; //We want a number between 100-200 int Range= (max-min)+1; /*This will give us the number 101 for our range. Why add 1? We're going to divide this using the % operator, which divides and returns a remainder. This means that our remainder can be as big as 100, instead of 99...so we can reach 200.*/ int Num = rand()%Range+min; /*We have a random number, divided by our range...this number will be a remainder between 0-100. If you add the min to that (100), you produce a number between 100-200. Perfecto. ^_^*/
Last edited by Krak; 03-06-2005 at 05:19 PM.
My compiler puts it there I don't bother with erasing it.Originally Posted by Krak
???Also honey
My computer is awesome.
I like calling people "honey, dear and sweetie". You'll just have to learn to live with it, love.Originally Posted by cerin
Hey, at least I helped you out, ya know.
And btw dear...you might want to replace those two main() parameters with 'void' to make sure you don't confuse anyone reading your code...You know....maybe someone who either doesn't know what they mean...or is confused as to why you bothered writing them in if you're not going to use them. Plus it makes your code shorter and seem a little more readable too.
I guess it really doesn't matter...your call, guy.
Last edited by Krak; 03-06-2005 at 06:05 PM.
How do I keep assigning values to a random throughout the program using time??Ya this is getting my discouraged I can't find it on google.
I've asked this question several times in different places, but no one answers. Does anyone know how to do this?!?!
My computer is awesome.