Mar 12, 2007

C++ program to generate 10 random numbers between 1 to 100

C++ program to generate random numbers between 1 and 100. For random() function, stdlib.h header file is required. randomize() function will generate different random numbers each time you run the program. If you don't include radomize() function it will generate same random numbers whenever you run this program.
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
main()
{
clrscr();
randomize();
for(int i=1;i<=10;i++)
{
cout << random(100)<<endl;
}
getch();
}

No comments:

Post a Comment