Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the code to locate and display the most expensive prices in the prices arr

ID: 3741719 • Letter: W

Question



Write the code to locate and display the most expensive prices in the prices array.
Use iteration to assign a price that is 10% less than the original price in each position in the prices array. CS 1320 Exam #2-b Practice Name: Complete the following point values named prices, with a length of 4. code to compute and display the average of all the values in a one-dimensional array of floating int i; double p prices 2. Write the code to locate and display the most expensive price in the prices array 3. Use iteration to assign a price that is 10% less than the original price in each position in the prices array

Explanation / Answer

1.

{

int i;

double sum = 0, avg = 0;

for(int i=0; i<4; i++)

{

sum = sum + prices[i];

}

avg = sum / prices.length;

}

2.

{

int max = prices[0];

for(int i=1; i<4; i++)

{

if(max < prices[i])

max = prices[i];

}

cout << "The most expensive price is : " << max << endl;

}

3.

{

for(int i=0; i<prices.length; i++)

{

prices[i] = prices[i] * 0.10;

}

}