# Thread: Another random number ?

1. ## Another random number ?

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.

2. check this.

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

4. The FAQ is your friend, sir. But sheesh, I'll tell you a nice, easy way.
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. ^_^*/
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.

5. Originally Posted by Krak
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.
My compiler puts it there I don't bother with erasing it.

Also honey
???

6. Originally Posted by cerin
???
I like calling people "honey, dear and sweetie". You'll just have to learn to live with it, love.

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.

7. 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?!?!