Tuesday, October 19, 2010

Random and Loops

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RandomLoops
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.GetRandom();
Console.ReadKey();
}

void GetRandom()
{
Random rand = new Random();

for (int counter = 1; counter <= 10; counter++)
{
int number = rand.Next(1, 1000);
Console.WriteLine(number.ToString());
}

int number2 = 1;
int counter2 = 0;
while (counter2 <= 10)
{
Console.WriteLine("Enter a number, 0 to quit");
number2 = int.Parse(Console.ReadLine());
counter2++;
}
}
}
}

No comments:

Post a Comment