1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sophie [7]
4 years ago
13

Task:create a struct that looks like:typedef struct person{ int age; double height;} Person;Create an array of Persons. Read dat

a for multiple persons from the keyboard. Stop when a negative age is found. Then find the average height, the average age, and the average ratio of age to height(age/height

Computers and Technology
1 answer:
Amiraneli [1.4K]4 years ago
6 0

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:

You might be interested in
What does a column represent in a chart?
earnstyle [38]
The correct option is C.
A column chart is defined as a chart in which the data are arrranged in column. It is normally used to show data changes over a period of time or for comparison purpose. A column in a chart refers to a vertical group of cells in a work book and it shows a series of data. 
8 0
3 years ago
SOMEONE PLEASE HELP!! i’ll give brainliest
miv72 [106K]

Display is 2.

Printer is 3.

Keyboard is 4.

Mouse is 1.

Hope this helps :D

7 0
3 years ago
Read 2 more answers
a term to describe article that can be displayed in their entirety as opposed to abstract and reference only?​
Maurinko [17]

Answer:

would it be term and tequnique?

Explanation:

oooooooo

7 0
3 years ago
Match the data type to their correct explanations,
sergejj [24]

Answer:

I'm positive memo is "allows inserting a large amount of text including numbers" i just took the test on Plato and got everything wrong but that one

4 0
3 years ago
Read 2 more answers
Read the section, "Junior Year." Why would someone chose to complete an apprenticeship after high school? How many occupations c
Tamiku [17]

An apprenticeship prepares you for a career through a structured program of on-the-job learning with classroom instruction, while you work and earn a salary. The programs can last from one to six years and you can choose careers in areas such as telecommunications, health care, computing, business support and the arts. The most common apprenticeships are in construction and manufacturing. If you like to work with your hands and your mind, you might want to consider an apprenticeship after high school. More than 850 occupations can be learned on the job through an apprenticeship.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Can I recover my data from HDD if I just started formatting but did not finish it? (I ceased it!)
    7·1 answer
  • What was the second phone made in the world called?
    5·1 answer
  • The first step in the information processing cycle involves the _____ of data.
    10·1 answer
  • Write a program segment that simulates flipping a coin 25 times by generating and displaying 25 random integers, each of which i
    5·1 answer
  • PowerPoint:
    7·2 answers
  • Describe at least two other companies that are direct or indirect competitors to your company. Explain how you will differentiat
    15·1 answer
  • Write a function to prompt the user to enter the information for one movie (title, release date, mpaa rating and number of stars
    8·1 answer
  • What are cell phones used for?
    8·2 answers
  • Justin bought some yarn from his favorite craft store. He can make 1 scarf with 3/5 of a ball of yarn. If he purchases 15 balls
    14·1 answer
  • I hs no life hahahaha
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!