63 135
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #58457 in C++ for brad

Question #58457
Write, compile, and run a C++ program that declares three one-dimensional arrays
named price, quantity, and amount. Each array should be declared in main() and be
capable of holding 10 double-precision numbers. The numbers to store in price are 10.62,
14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, and 3.98. The numbers to store in quantity
are 4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9, and 4.8. Your program should pass these three arrays to
a function named extend(), which should calculate elements in the amount array as the
product of the corresponding elements in the price and quantity arrays (for example,
amount[1]ƒ= price[1]ƒ*ƒquantity[1]). After extend() has passed values to the amount
array, the values in the array should be displayed from within main().
Expert's answer
#include <iostream>

using namespace std;

void extend(double price[10], double quantity[10], double* amount)
{
for (int i(0); i < 10; i++)
{
amount[i] = price[i] * quantity[i];
cout << "amount[" << i + 1 << "] = " << amount[i] << endl;
}
system("pause >> void");
}

int main()
{
double amount[10];
double price[10] = {10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98},
quantity[10] = { 4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9, 4.8 };
extend(price, quantity, amount);
}

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

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions