Ex 3: Simulate rolling a pair of dice. Write a program that roll the pair of dice 12 times. (Display each roll).
static void Main(string[] args)
{
Random rand = new Random();
int dice1 = 1;
int dice2 = 1;
int counter = 1;
while (counter <= 12)
{
dice1 = rand.Next(1, 7);
dice2 = rand.Next(1, 7);
Console.WriteLine("Two Rolling No: {0} and {1}", dice1, dice2);
counter++;
}
Console.ReadKey();
}
No comments:
Post a Comment