Hi iam working on a problem given to me by my teacher.The problem is
!.People from different states send their application to participate in the dance competition organised at the country level.Only 30 people will be selected to take par in the competition.Participants will be selected randomly from one state.No more than 5 participants can take part in the competition.We have to write a function to print names of 20 people selected randomly to take paet in the competition.

Can anyone help me on this question.

Recommended Answers

All 3 Replies

??? First you say that 30 people will be selected to compete. Then, you say 5 participants can compete. Then, you want the names of 20 competitors. Either make up your mind or clarify your assignment.

??? First you say that 30 people will be selected to compete. Then, you say 5 participants can compete. Then, you want the names of 20 competitors. Either make up your mind or clarify your assignment.

Actually 30 peoples are to be selected 5 from each city and there are 6 cities given.These 5 people should be selected randomly

I would have an array of names of people from each city. That is, have 6 arrays, one for each city.
Then, have a for loop like such:

for (i = 0; i < 5; i++)
{
     result = rand();
     contestant[6*i + 1] = denver[result];
     contestant[6*i + 1] = cleveland[result];
     ........
     ........
     ........
     ........
}

That will fill up the 30 contestant slots with 5 from each city.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.