Answer to Question #234911 in C for New

Question #234911
Using an array sales[], write a program that accepts sales from 8 sales reps, determine and display the following:

Average sales
All sales above calculated average
Highest and lowest sales
1
Expert's answer
2021-09-08T14:16:45-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Andy
19.08.22, 01:11

Great answer. Well assisted

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS