Possible Duplicate:
Generate a random number within range?
I am trying to make it so when the code is executed, I can type the max number in command prompt to redefine the max number and generate a new random number inbetween 0 and new Max number.
Did I do this correctly?
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main()
{
int randomnumber ;
int max;
srand( time(NULL) );
scanf("Enter total number of students %d",&max);
randomnumber=rand()% 30;
printf("This is your random number\n %d",randomnumber);
getchar();
return 0;
}