Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Based on the previous question. Use a loop to prompt the user to enter the amount sold of each fruit. Once the sales numbers have

Based on the previous question.
Use a loop to prompt the user to enter the amount sold of each fruit. Once the sales numbers have been entered, the program should pass the array holding the sales count to a function that computes and returns the average number of sales.
/******************************************************************************
* Module 5: Assignment (Fruit Stand)
* Working with arrays, parallel array
*******************************************************************************/
#include
#include
using namespace std;
int
average
(int array[]);
int main()
{
cout<<"Welcome to fruit stand!
";
#### fruits[5]= ####"orange", "mango", "apple", "pineapple", "banana"####;
#### amountSold[ #### ]={};
cout<< "Please enter the amount of fruit sold
";
for
(int i =0; i <5; i++){
cout << fruits[ i ]<<": ";
cin >> amountSold[ i ];
}
cout <<"An average sold is : "<< average(
);
return 0;
}
int average(int array[]){
int total =0;
for(int i =0; i <5; i++){
total += array[ i ];
}
return total/
;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions