Question in Parallel Arrays
I'm trying to understand how parallel arrays work..how can I print the price of an item in one column and the difference between average and the price in the next column- for all ten items?
Code:
#define Max 10
#include <iomanip.h>
#include <stdlib.h>
main()
{ float Price[Max],Avg;int Diff; float Sum=0; int C; int Price[10];
for(C=0;C<Max;C++)
{Price[Max]=0;}
for(C=0;C<Max;C++)
{ cout<<"\n Enter Price "<<C+1<<" : ";
cin>>Price[C];}
for(C=0;C<Max;C++)
{ Sum=Sum+Price[C];}
Avg=Sum/9;
for(C=0;C<Max;C++) this is the part where I don't know how to print price in one column and the difference between average and price in the next column..how?
{cout<<Price[C][Avg];}
cout<<"\n Sum = "<<Sum<<endl;
cout.setf(ios::floatfield, ios::showpoint);
cout.setf(ios::fixed);
cout<<setprecision(2);
cout<<Avg<<endl;
system("PAUSE");
return 0;
}
Thanks