C Program to Generate Random Numbers

C Programming Examples


This C program generates numbers randomly using random function.

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

Program:

#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:

c-random-numbers



Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram

Notifications

Updates are enabled for this browser.

Receive new tutorials, articles and learning resources. You can turn updates off anytime.

Test browser code

Use this code in admin to send a test notification to this browser.