C Program to Generate Random Numbers

C Programming Examples
C String Programs
C Loop Programs
C Function Programs
C Array Programs
C Integer Number Programs
C File I/O Programs

This C program generates numbers randomly using random function.

In this program for loop is used to call rand() function multiple times.

#include <stdio.h>
#include <stdlib.h>

int main()
    int c, n;
    printf("Ten random numbers in [1,100]\n");
    for (c = 1; c <= 10; c++)
        n = rand()%100 + 1;
        printf("%d\n", n);    
    return 0;
Program Output:


Scroll Back to Top