Random Number Generation

Hi all. I want to make my program to generate a random number and then add that number to a variable. Could you show me how it's done if I want my number to be between, lets say 0 and 50? Thanks.
You can try this:
1
2
int v;
v = rand() % 51;//generates value between 0 and 50; 

Happy coding!
you will want:
srand ( time(NULL) );
long int 'what ever you want' = 0;
long int 'what you wanted' = rand() % (10000 * 1);
Thanks to both of you.
could you explain those long int?

long int 'what ever you want' = 0;
long int 'what you wanted' = rand() % (10000 * 1);


i am trying to program a guessing game that generates a different random number every time i run it, right now it always generates the same number so there is no point of this program :D

could somebody help?
Topic archived. No new replies allowed.