C Program to Generate Random Numbers

« Previous Program Next Program »

Generate Random Numbers in C

To generate random numbers in C programming, use rand() function to generate random numbers. And if you want to generate different random numbers at each time when you compile and run the program, then use srand() function before generating the random numbers using rand() function.

C Programming Code to Generate Random Numbers

Following C program generate 100 random numbers using rand() function of stdlib.h library function:

/* C Program - Generate Random Numbers */
void main()
	int i;
	for(i=0; i<100; i++)

When the above c program is compile and executed, it will produce the following result:

c program generate random numbers

Same Program in Other Programming Language

You may also like same program in other programming languages:

« Previous Program Next Program »


Quick Links
Signup - Login - Give Online Test