In: Computer Science
According to the question let us make some assumptions:-
The complete algorithm of the given problem is as follows:-
CountBottles (box[], n)
The implementation of above algorithm using C code is as follows:-
#include<stdio.h>
void CountBottles(int box[],int n)
{
int i;
float avg,sum=0;
for(i=0;i<n;i++)
{
printf("\nBox %d contains %d bottles",i+1,box[i]);
sum=sum+box[i];
}
avg=sum/n;
printf("\naverage of juice bottles per box is: %f", avg);
}
int main()
{
int box[5]={8,7,9,7,9};
CountBottles(box,5);
return 0;
}
The output of the above code is as follows:-
Box 1 contains 8 bottles
Box 2 contains 7 bottles
Box 3 contains 9 bottles
Box 4 contains 7 bottles
Box 5 contains 9 bottles
average of juice bottles per box is: 8.000000