Create 10 different Random numbers
Below is the program in C language that will create and display 10 different random numbers.
This program will make use of srand function in C.
In order to generate random numbers, srand is usually initialized to some distinctive value. We will also make use of time function as time function will return different value at different time. The value returned by the time function will act as a parameter to srand function.
Here is the code…
#include#include #include void main() { int i; clrscr(); srand( (unsigned)time( NULL ) ); for (i=0; i<10; i++) printf("%d ", rand()); printf("\n"); getch(); }
great use of rand function
Thanks
can anyone plz post the ans for same qstn using pointers?????