Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C PROGRAMMING CODE STRICTLY DO NOT USE STRINGS/POINTERS ALLOWED TO USE: User Def

ID: 3539733 • Letter: C

Question

C PROGRAMMING CODE


STRICTLY DO NOT USE STRINGS/POINTERS


ALLOWED TO USE: User Defined functions, Arrays, Selection, logical statements, loops, relational operators etc.


I need the code will award all points and stars.


Problem: A number of teams are competing in a race. The team with the most individuals among the first 25 to complete the race will be declared the winner. When multiple teams have the same number of individuals among the first 25 to complete the race then the team with the individual that finished first will be declared the winning team. Accept twenty- five integers as input in order from the first individual to complete the race to the twenty-fifth individual completing the race. The integer entered represents the individual's team number. Your program will report the number of the winning team.

Example Execution #1:

%u2022 Team #7 has four individuals among the top 25.

Example Execution #2:

%u2022 Two teams have eight individuals among the top 25, team #5 is declared the winner because their first individual to complete the race finished ahead of the first individual that finished the race from team #4.

Explanation / Answer

Hi ,

You can try out the following code. I tested this with your inputs. Hope it Helps :)


#include<stdio.h>

#include<conio.h>


void main()

{


int vals[25];

int i=0,j=0;

int temp[25];

int Max=0, Maxcount=0;

for(j=0;j<25;j++)

{

temp[j]=0;

}

clrscr();


printf("Enter the top 25 finishers:");

for(i=0;i<25;i++)

{

scanf("%d",&vals[i]);

}

for(i=0;i<25;i++)

{

temp[vals[i]-1] = temp[vals[i]-1] + 1;

printf("%d :",temp[vals[i]-1]);

}


for(i=0;i<25;i++)

{

printf(" ", temp[i]);

if(temp[i]>Maxcount)

{

Max=i+1;

Maxcount=temp[i];

}

}


printf ("Winning Team : %d ", Max);

printf ("Winning Team has %d members", Maxcount);

getch();

}