Discussion Forums

New User? Please read instructions!

C program to generate random numbers  

  RSS

thiyagarajan.s
Active Member
Joined: 1 month  ago
Posts: 14
27/01/2017 10:09 am  

C program to generate random numbers


ReplyQuote
admin
Eminent Member
Joined: 5 years  ago
Posts: 26
10/02/2017 10:43 am  

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.


ReplyQuote
  
Working

Please Login or Register

Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Share this website !!!
Facebook Twitter Linkedin

Close
We Support JALLIKATTU !!!
We Support JALLIKATTU!
By Fresh2Refresh.com
Show Your Support as well. Thanks!