Create two arrays called Names and Times. The first array will store the names o
ID: 3768933 • Letter: C
Question
Create two arrays called Names and Times. The first array will store the names of the swimmers, and the second their times. Assume that there are 6 swimmers in a competition. ask the user to input the names in the first array, and the times in the second( use a loop to do that). Display the name and the time of the fastest swimmer and the slowest swimmer. Create two arrays called Names and Times. The first array will store the names of the swimmers, and the second their times. Assume that there are 6 swimmers in a competition. ask the user to input the names in the first array, and the times in the second( use a loop to do that). Display the name and the time of the fastest swimmer and the slowest swimmer.Explanation / Answer
C Programme:
/* Displaying of Fastest swimmer and the slowest swimmer in the Race */
#include<stdio.h>
int main()
{
char swimmers[6];
float rank[6], high, low;
int i,j;
for(i=1;i<=6;i++)
{
printf(" Enter %d Simmer Name: ", i);
scanf("%s",&swimmers[i]);
}
for(j=1;j<=6;j++)
{
printf(" Enter %d Simmer Time: " j);
scanf("%f",&rank[j]);
}
for(i=1;i<=6;i++)
{
printf(" Simmer %d is: ", i);
}
for(j=1;j<=6;j++)
{
printf(" Simmer Timings %f: ", j);
}
high=rank[1];
for(i=2;i<=6;i++)
{
if(high<rank[i])
high=rank[i];
}
printf("Slowest Swimmer Name: %s",swimmers[i]);
printf("Slowest Swimmer Time: %f",rank[i]);
low=rank[1];
for(i=2;i<=6;i++)
{
if(low>rank[i])
low=rank[i];
}
printf("Fastest Swimmer Name: %s",swimmers[i]);
printf("Fastest Swimmer Time: %f",rank[i]);
return 0;
}
/* Program Ends */
Output:
Enter 1 Simmer Name: John
Enter 2 Simmer Name: Deepak
Enter 3 Simmer Name: Abhi
Enter 4 Simmer Name: Rcokstar
Enter 5 Simmer Name: Surya
Enter 6 Simmer Name: Navneeth
Enter Simmer 1 Time: 52
Enter Simmer 2 Time: 55
Enter Simmer 3 Time: 60
Enter Simmer 4 Time: 85
Enter Simmer 5 Time: 48
Enter Simmer 6 Time: 58
Simmer 1 is: John
Simmer 2 is: Deepak
Simmer 3 is: Abhi
Simmer 4 is: Rcokstar
Simmer 5 is: Surya
Simmer 6 is: Navneeth
Simmer Timings: 52.000000
Simmer Timings: 55.000000
Simmer Timings: 60.000000
Simmer Timings: 85.000000
Simmer Timings: 48.000000
Simmer Timings: 58.000000
Slowest Swimmer Name:Rcokstar
Slowest Swimmer Time:85.000000
Fastest Swimmer Name:Surya
Fastest Swimmer Time:48.000000
------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.