#include<stdio.h>
#include<conio.h>
main()
{
float wares[8];
float aver,highestP,lowestP;
void readprice(float price[8]);
float averPrice(float price[8]);
float highPrice(float price[8]);
float lowePrice(float price[8]);
void prtprice(float price[8],float ave);
readprice(wares);
aver=averPrice(wares);
highestP=highPrice(wares);
lowestP=lowPrice(wares);
printf("The highest Price=%6.2f\n",highestP);
printf("the lowest Price=%6.2f\n",lowestP);
printf("The average Price=%6.2f\n",aver);
prtprice(wares,aver);
getch();
}
void readprice(float price[8])
{
int i;
printf("Enter 8 ware’s price:\n");
for(i=0;i<8;i++)
scanf("%f",&price[i]);
printf("The price of 8 wares is :\n");
for (i=0;i<8;i++)
printf("%6.2f\t",price[i]);
printf("\n");
return;
}
float averprice(float price[8])
{
float sum=0.0;
float ave;
int i;
for (i=0;i<8;i++)
sum=sum+price[i];
ave=sum/8;
return(ave);
}
float highprice(float price[8])
{
float high_temp;
int i;
high_temp=price[0];
for(i=0;i<7;i++)
if (high_temp<price[i+1])
high_temp=price[i+1];
return (high_temp);
}
float lowprice(float price[8])
{
float lowe_temp;
int i;
lowe_temp=price[0];
for(i=0;i<7;i++)
if (price[i]>price[i+1])
lowe_temp=price[i+1];
return(lowe_temp);
}
void prtprice(float price[8],float ave)
{
int i;
printf("The ware which are higher than average price:\n");
for(i=0;i<8;i++)
if(price[i]>ave)
printf("%6.2f\t",price[i]);
return;
}