Zoo
Zoo
h>
int main()
{
struct information
{
char name[20];
float grass;
float water;
};
struct information details[5];
int i;
for(i=0;i<5;i++)
{
printf("\nEnter the name of the animal %d:",i+1);
scanf("%s",details[i].name);
for(i=0;i<5;i++)
{
sum_g=details[i].grass+sum_g;
sum_w=details[i].water+sum_w;
avg=(float)sum_w/5;
if (max<details[i].grass)
{
max=details[i].grass;
j=i;
}
}
printf("\nTotal amount of grass needed per day=%.2f",sum_g);
printf("\nThe animal that consumes maximum amount of grass every day is
'%s'",details[j].name);
printf("\nThe average water consumed per day by the animals=%.2f",avg);
for (i=0;i<5;i++)
{
if(avg<details[i].water)
printf("\n'%s' consumes more water than the average water consumed by all the animals
together",details[i].name);
}
return 0;
}