Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Microsoft Word - Document1 Execute to let user enter some prices to display their highest price, total sum, average, and the price that is most close to the average. 1. The program's main function...

1 answer below »
Microsoft Word - Document1
Execute to let user enter some prices to display their highest price, total sum, average,
and the price that is most close to the average.
1. The program's main function must call the following three functions in the given
order. No any external variables are used by main.
• void get_prices(int *, double []);
• double *max_avg_sum(double [], int, double *, double *);
• void near_avg(double [], int, double, double *);
2. get_prices first prompts a message "How many prices will you enter?" and
ased on this input number, it reads all prices into a double type a
ay, which is
defined by the 2nd parameter of this function. The price values could be positive,
negative, or zero, possibly duplicated but each must be entered with a space to
separate it from the previous price (e.g., XXXXXXXXXX XXXXXXXXXXThe
total number of prices is made available to the main via the first parameter of this
function, which is an int pointer (i.e., it's passed by reference or address). **This
function assumes both inputs from user are always valid.
3. max_avg_sum is the most complicated function of this program. The main of
the program calls it to find the highest or maximum value, the total sum, and the
average of prices given in its first parameter, which is a double type a
ay. The
2nd parameter is a passed-by-value integer, which tells the function the total
number of prices (i.e., the size of the a
ay) so it can easily calculate the desired
data.
• Among the three calculated data, total sum and average are made
available to the main via the last two parameters of this function. They
oth are declared to be a double type pointer.
• The last calculated data is the highest or maximum value of prices.
Whichever item in the a
ay is determined to have this highest value, its
address is expected to be returned by this function to the caller (i.e.,
main). This satisfies the function's return type, which is a double type
pointer.
4. Once the main gets the highest price, the total sum of all prices, and their
average, it prints them as shown in the above screenshot. All price value must be
printed with '$' and only two decimal digits.
5. near_avg is void function. main calls it at the end of the program to find which
price in the input a
ay is most close to the price average. Like the previous
function, it knows all prices and the total number of prices via its first two
parameters. Instead of re-calculating the price average, it receives the average
from the caller via its third parameter. Once it compares all prices to the average
and find the one nearest to the average, this price value is made available to the
calle
main via the last parameter, which is a double type pointer. Once this
function returns to main, main needs to display the price nearest to the average
as shown in the above screenshot.
Answered Same Day Jun 16, 2021

Solution

Mohd answered on Jun 21 2021
147 Votes
PriceProject
in/Debug/PriceProject.exe
PriceProject/main.c
#include #include void get_prices(int *number, double inputNumber[])
{
printf("Enter your %d prices, each is separated by a space: ",*number);
printf("\n");
int i=0;
for (i = 0; i < *number; i++)
{
float values = 0.0;
scanf("%f", &values);
inputNumber[i] = values;
}
}
double *max_avg_sum(double inputNumber[], int number, double *sum, double *avg)
{
int i=0;
double s = 0.0;
double max...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here