Sunday, 9 April 2017

C# Program to Generate Random Numbers

  1. /*
  2.  * C# Program to Generate Random Numbers
  3.  */
  4. using System;
  5. class Program
  6. {
  7.     static void Main()
  8.     {
  9.         Console.WriteLine("Some Random Numbers that are generated are : ");
  10.         for (int i = 1; i < 10; i++)
  11.         {
  12.             Randfunc();
  13.         }
  14.     }
  15.     static Random r = new Random();
  16.     static void Randfunc()
  17.     {
  18.         int n = r.Next();
  19.         Console.WriteLine(n);
  20.         Console.ReadLine();
  21.     }
  22. }
Here is the output of the C# Program:
Some Random Numbers that are generated are : 
1234567
8754352
9864930
8352048
1920472
2846104
7649207
4928756
9261746

No comments:

Post a Comment