Answer to Question #252200 in C for Sam

Question #252200
Write a program/application that stores 28 prices such as 1.1, 1.2, 1.3, 1.5 numbers up till 28
-- Entry by a user in response to a prompt
-- Display the sum of all the prices
-- Display all prices less than 5 downward
-- Calculate the average
-- Display all values that are higher than the calculated average

NOTE: Topic under display and arrays

Thank You..
1
Expert's answer
2021-10-16T17:23:53-0400
#include<stdio.h>
int main(){
	
	
	float arr[28];
	int i;
	printf("Enter prices:\n");
	for(i=0; i<28; i++){
		printf("Prices: %d\n",(i+1));
		scanf("%f",&arr[i]);
	}
	
	float sum = 0;
	int n;


	printf("All prices less than 5 downward:\n");
	for(n=0; n<28; n++){
		sum +=arr[n];
		
		if(arr[n]<5){
			printf("%f  ", arr[n]);
		}
		else{
			printf(" ");
		}
		printf("\n");
	}
	printf("The sum of all the prices: %f\n", sum);
	
	float average = sum /28;
	printf("The average of all the prices: %f\n", average);
	printf("All values that are higher than the calculated average");
	
	int k=0;
	for(k=0; k<28;k++){
		if(arr[k]>average){
		printf("%f ", arr[k]);	
		}
		else{
			printf(" ");
		}
	}
	
}

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

Sam
17.10.21, 03:52

Thanks

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS