#include <stdio.h>
#define SIZE 8
int main()
{
float sales[SIZE];
int i;
float averageSales;
float lowestSale;
float highestSale;
float sum=0;
for(i=0;i<SIZE;i++){
printf("Enter sales[%d]: ",(i+1));
scanf("%f",&sales[i]);
sum+=sales[i];
}
averageSales=sum/(float)SIZE;
lowestSale=sales[0];
highestSale=sales[0];
printf("Average sales is: %.2f\n",averageSales);
printf("All sales above calculated average are:\n");
for(i=0;i<SIZE;i++){
if(sales[i]>averageSales){
printf("%.2f ",sales[i]);
}
if(sales[i]<lowestSale){
lowestSale=sales[i];
}
if(sales[i]>highestSale){
highestSale=sales[i];
}
}
printf("\nLowest sale is: %.2f\n",lowestSale);
printf("Highest sale is: %.2f\n",highestSale);
scanf("%d",&sales[0]);
return 0;
}
Comments
Great answer. Well assisted
Leave a comment