12 ch 5 warm up: people's weights (java) (1) prompt the user to enter five numbers, being five people's weights. store the numbers in an array of doubles. output the array's numbers on one line, each number followed by one space. (2 pts) ex: enter weight 1: 236.0 enter weight 2: 89.5 enter weight 3: 142.0 enter weight 4:

Respuesta :

#include <stdio.h>

int main()
{
double d[5] , total = 0, average = 0, max = 0;
int i = 0;
for(i=0; i<5; i++){
printf("Enter Weight %d: ", (i+1));
scanf("%lf", &d[i]);
}
printf("You entered: ");
for(i=0; i<5; i++){
printf("%lf ", d[i]);
if(max < d[i]){
max = d[i];
}
total = total + d[i];
}
average = total / 5;
printf("\nTotal weight: %lf\n", total);
printf("Average weight: %lf\n", average);
printf("Max weight: %lf\n", max);
  
return 0;
}