I just need help with what im doing, I get confused on how to pass arrays through functions therfore making my peice of code not working, also on how to use the arrays to get the product. any help would be greatly appreciated.
Assigenment;;;
Write a program that declares 3 single-dimensional arrays named Price,Quantity, and Amount. Each array should be declared in main() and should be capable of holding 10 double-precision numbers. The numbers to be stored in price are{10.62,14.89,13.21,16.55,18.62,9.47,6.58,18.32, 12.15,3.98}
and the numbers in quantity are{4,8.5,6,7.35,9,15.3,3,5.4,2.9,4.8}
Have the program pass these three arrays to a function called extend(), which calculates the elemets in the Amount array, as the product of the equivalent in the Price and Quantity arrays( for example, Amount[1]= Price[1]*Quantity[2].)
After extend() has put values into the Amount array, display the values in the array from within main(). Write extend() using pointers.
-------------------------------------------------------------------
this is what i have so far, it doesnt compile becuase its not correct i think.
Code:
#include <iostream.h>
#include <iomanip.h>
void extend(double[],double[],double[]);
main()
{
const int Size=10;
double Price[Size]={10.62,14.89,13.21,16.55,18.62,9.47,6.58,18.32,12.15,3.98};
double Quantity[Size]={4,8.5,6,7.35,9,15.3,3,5.4,2.9,4.8};
double Amount[Size];
extend(Price,Quantity,Amount);
cout<<"\n"<<"Price"<<setw(10)<<"Quantity"<<setw(9)<<"Amount"<<endl;
cout<<"\n\r------------------------"<<endl;
cout<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(4);
cout<<Price<<Quantity<<Amount<<endl;
return 0;
}
void extend(double *Price, double *Quantity, double *Amount)
{
const int Size=10;
int i;
for(i=0;i<Size;i++)
return;
}