108k views
3 votes
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:

User Tomooka
by
7.3k points

1 Answer

2 votes

#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("\\Total weight: %lf\\", total);
printf("Average weight: %lf\\", average);
printf("Max weight: %lf\\", max);

return 0;
}

User Zavior
by
6.9k points