C program to generate random numbers

1. Online Compilers - Compile & Run your C/C++ programs:

✅ Online Compilers

2. Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





C program to generate random numbers:

#include <stdio.h>

#include <stdlib.h>


int main()

{

int i, n;


printf(“Five random numbers between 1 and 100000\n”);

for (i = 1; i <= 5; i++)

{

n = rand()%100000 + 1;

printf(“%d\n”, n);

}

return 0;

}

 

Output:

Five random numbers between 1 and 100000

89384

30887

92778

36916

47794

 

Note: Above random numbers will be different every time we execute this C program.

1. Online Compilers - Compile & Run your C/C++ programs:

✅ Online Compilers

2. Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Share this website !!!
Facebook Twitter Linkedin