7
Answers

Audience and Seat#

Maha

Maha

11y
1.1k
1
Only one seat should be allocated to one audience randomly. More than one audience can't have same seat or vice versa. How can this program be completed with these conditions?

using System;

class Program
{
public static void Main()
{
int seats = 10;
int audience = 10;

int[] audArray = new int[audience];

Random r = new Random();

Console.WriteLine("{0 ,4} {1, 5}", "Audience", "Seat#");

for (int i = 1; i < audience; i++)
{
int x = r.Next(1, seats);

audArray[i] = i;

Console.WriteLine("{0, 3} {1, 6}", audArray[i], x);

}
Console.Read();
}
}

Answers (7)