Generate Random Number in Range
In this example, you will get a program code of 10 random number generator between 1 to 100 in c programing. Here we are using rand function which is helpful to make a random number generator easily. Rand() in c is defined in the <stdlib.h> header file.
Program code of 10 Random Number Generator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <stdio.h> #include <conio.h> #include <stdlib.h> int main() { int i, n=10, m=100, t; printf (" %d random numbers from 0 to %d number are: n", n, m); for (i = 1; i <= n; i++) { t = rand()%m + 1; printf (" %d ", t); } getch(); } |
Output
Check out our other C programming Examples