svetlozar_kirkov

Random Numbers (Exercise)

Oct 7th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2.  
  3. class ConsoleTests
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Number of random numbers: ");
  8.         int counts = int.Parse(Console.ReadLine());
  9.         Console.Write("From: ");
  10.         int starting = int.Parse(Console.ReadLine());
  11.         Console.Write("To: ");
  12.         int ending = int.Parse(Console.ReadLine());
  13.         Console.WriteLine();
  14.         GenerateRandoms(counts,starting,ending);
  15.         Console.WriteLine();
  16.     }
  17.  
  18.     static void GenerateRandoms(int count, int start, int end)
  19.     {
  20.         Random rnd = new Random();
  21.         for (int i = 1; i <= count; i++)
  22.         {
  23.             Console.Write("{0} ", rnd.Next(start, end+1));
  24.         }
  25.         Console.WriteLine();
  26.        
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment