Instructions
The Durban July is an annual horse race that has been presented every year since 1897. Write a C/C++ program to handle registrations for the race. The program must meet the following specifications:
#include <stdio.h>
struct horse{
char name[20];
int age;
int height;
float duration;
};
int main()
{
int flag = 0;
int number;
printf("ENter the number of horses");
scanf("%d",&number);
struct horse record[number];
for(int i =0;i<number;i++)
{
printf("Please enter the name of the %d horse",i+1);
scanf("%s",&record[i].name);
printf("Please enter the age of the %d horse",i+1);
scanf("%d",&record[i].age);
printf("Please enter the height of the %d horse",i+1);
scanf("%d",&record[i].height);
printf("Please enter the duration of the %d horse",i+1);
scanf("%f",&record[i].duration);
}
printf("The details of the horses are as follows \n");
for(int i =0;i<number;i++)
{
printf("Name = %s,Age = %d,Height = %d,Duration =
%f",record[i].name,record[i].age,record[i].height,record[i].duration);
printf("\n");
}
for(int i =0;i<number;i++)
{
if(flag<record[i].duration)
{
flag = i;
}
}
printf("The Favourite horse is \n");
printf("Name = %s,Age = %d,height = %d,Duration =
%f",record[flag].name,record[flag].age,record[flag].height,record[flag].duration);
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.