Thursday, September 8, 2011

Program to generate Random Numbers

#include
#include
#include
int main(){
int num;

//initialize the random number generator
randomize();

//Generating the random number
num = random(99999);

//Printing the random number
printf("%d",num);
getch();
return 0;
}

Note: random function random(val) generates any number between 1 to num -1 . randomize() function is used only to initialize the random number generator. It internally call the used the header file time.h

No comments: