Respuesta :
Answer:
Check the explanation
Explanation:
person.c
#include <stdio.h>
#include <stdlib.h>
typedef struct person
{
 int age;
 double height;
}Person;
void getAverage(Person persons[], int max)
{
 int i, totAge=0;
 double avgAge = 0.0, avgHeight = 0.0, ratio=0.0, totHeight = 0;
 //calculate the Of age, height and the ratio Of to height(age/height):
 for(i=0;i<max;i++)
 {
   totAge = totAge + persons[i].age;
   totHeight = totHeight + persons[i].height;
 }
 //calculate the average
 avgAge = totAge/max;
 avgHeight = totHeight / max;
 ratio = avgAge / avgHeight;
 //output the results
 printf("\nthe average of age is: %lf", avgAge);
 printf("\nthe average of height is: %lf", avgHeight);
 printf("\nthe average ratio of age to height is: %lf", ratio); Â
}
int main()
{
 //variables declaration
 int id=0;
 Person p[10];
 //read data from keyboard, which are the age and the height of person
 while(1)
 {
   printf("\nid: %d", id + 1);
   printf("\nplease enter the age: ");
   scanf("%d", &p[id].age);
   if(p[id].age < 0)
     break;
   printf("please enter the height: ");
   scanf("%lf", &p[id].height);
   id++;
 }   Â
 //call getAverage function
 getAverage(p, id); Â
 return 0;
}
Kindly check the Screenshot and Output in the attached images below:
