More on Two-Dimension Arrays..Help!
So far I've got my program to accept prices for 10 items, calculate the sum, and in function CalcAvg, calculate the average. The next part of my assignment I'm totally blind on how to do ..
I need to make another function to print the price of each item and the difference between average and price of each item in column format.
HOW?? I'm pretty much a beginner, so please try to break it down if u can..thanks
Code:
#define Max 10
#include <iomanip.h>
#include<stdlib.h>
float CalcAvg(float Sum, int C)
{ return (Sum/Max); }
main()
{ float Price[Max],Avg; float Sum=0;
int C, I;
for(C=0;C<Max;C++)
{Price[Max]=0;
cout<<"\n Enter Price "<<C+1<<" : "; cin>>Price[C];
Sum=Sum+Price[C];}
cout<<" Avg= "<<CalcAvg(Sum,C);
cout<<"\n Sum = "<<Sum<<endl;
Avg=CalcAvg(Sum,C); //UP TO THIS PART IS CORRECT
for(C=0;C<Max;C++)
{ } //here is where I don't know what to do..do I even need this loop?
cout.setf(ios::floatfield, ios::showpoint);
cout.setf(ios::fixed);
cout<<setprecision(2);
system("PAUSE");
return 0;
}