Pages

Sunday, March 17, 2013

C#: Display Random Numbers

public void RandomNumber()
 {
 Random rnd = new Random();
int[] randArray = new int[10];
 int rand1 ;
for (int i = 0; i < 10; i++)
{
 rand1 = rnd.Next(1, 10); // Random numbers between 1 and 10
 Console.WriteLine(rand1);
 }
}

Output: 8
              2
              6
              4
              5
              7
              6
              3
              3
              2
              


No comments:

Post a Comment