8. The following code needs a function called stats (). The function takes a pointer to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
8. The following code needs a function called stats (). The function takes a pointer to an array of integers and returns the average value of the numbers in the array. In addition, a side effect of the function is that the values array_max and array_min will contain the largest and smallest value in the array after the stats function is called. You must write the stats () function, including the arguments that are passed to the function. Other than how the stats () function is called no other changes to main () are permitted. No global variables are permitted. // assume this file is called my_prog.c, and you make an executable file // called my_prog. It is run using ./my_prog 1000 #include <stdlib.h> #include <stdio.h> int main(int arge, char *argv[]) { } int *array; int array_max, array_min, array_size; double array_average; int j; array_size=atoi (argv[1]); array = (int *) malloc( array_size*sizeof (int)); // fill the array with random numbers for(j=0; j < array_size; j++) array[j] = array_size* drand48 (); array_average stats ( printf("Avg=8&g, Max-&d, Min=%d\n", = free (array); return 0; // you must fill in details here array_average, array_max, array_min); 8. The following code needs a function called stats (). The function takes a pointer to an array of integers and returns the average value of the numbers in the array. In addition, a side effect of the function is that the values array_max and array_min will contain the largest and smallest value in the array after the stats function is called. You must write the stats () function, including the arguments that are passed to the function. Other than how the stats () function is called no other changes to main () are permitted. No global variables are permitted. // assume this file is called my_prog.c, and you make an executable file // called my_prog. It is run using ./my_prog 1000 #include <stdlib.h> #include <stdio.h> int main(int arge, char *argv[]) { } int *array; int array_max, array_min, array_size; double array_average; int j; array_size=atoi (argv[1]); array = (int *) malloc( array_size*sizeof (int)); // fill the array with random numbers for(j=0; j < array_size; j++) array[j] = array_size* drand48 (); array_average stats ( printf("Avg=8&g, Max-&d, Min=%d\n", = free (array); return 0; // you must fill in details here array_average, array_max, array_min);
Expert Answer:
Answer rating: 100% (QA)
The screenshot shows a partial C code for a program that is intended to calculate some statistics of ... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
More Co has two divisons L & MDuring July the Cont Margin in Division L was $60,000 The Contribution margin ratio in Division M was 40% & its sales were $250,000 Division M's segment margin was...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Write a program to count the number of times the words in an input text file occur. The WordCount Structure Define a C++ struct called WordCount that contains the following data members: An array of...
-
Jaclyn Hargrove is the owner of six Pickwick Restaurants. For the past 10 years, she has always relied on her accountant to analyze her financial statements. Jaclyn feels that if she were able to...
-
On August 1, 2012, Trico Technologies, an aeronautic electronics company, borrows $20 million cash to expand operations. The loan is made by FirstBanc Corp. under a short-term line of credit...
-
The thin circular disk of mass m and radius r is rotating about its z-axis with a constant angular velocity p, and the yoke in which it is mounted rotates about the x-axis through OB with a constant...
-
The accountant for Flenderson Roofing, Inc., posted adjusting entries (a) through (e) to the accounts at December 31, 2010. Selected balance sheet accounts and all the revenues and expenses of the...
-
Martin Manufacturing decided to raise additional long-term capital by mortgaging an industrial park it owned. First National Loan Co. agreed to lend Martin $1 million and to take a note and first...
-
Assume a private equity firm raises a $9.4 billion buyout fund and charges a management fee of 1.07%. Calculate the present value of the management fees (in millions) to the private equity firm...
-
A probability plot of 66 yr of peak discharges for the Kentucky River near Salvisa, Kentucky, is shown in Fig. P3-19 (a) What probability distribution is being used? (b) What are the mean and...
-
Tim felt he needed to go full-time to take the SkyBOX to the next level. Can you think of ways he could have continued building up the SkyBOX while sticking with a part-time approach? What would have...
-
How important is developing strategic plans in sports marketing? What kind of impact does a great plan make? What if your strategic plan isn't so good? How important is it to understand the market...
-
How can user-centered design principles be applied in product development?
-
How might you incorporate these learning approaches in your future learning experience? 1 . online resources and communities 2 . real world experience 3 . continuous learning and adaptation
-
An airline is currently evaluating two separate strategies for the forthcoming Winter 2021/2022 season for short haul operations. A number of scenarios are being evaluated versus the actual...
-
How Much Is The Accrued Interest Since Last Coupon Payment? 0.355 Invoice Price Quite Often The Bond Is Purchased Between Coupon Payments. The Clean For Fiat) Price Is Defined The Present Value Of...
-
W. A. P. for reading and writing class objects.
-
Show that the peak of the black body spectrum as a function of ? is given by eq. (22.14) kg T Wmax = 2.82
-
Write a method called lastIndexOf that accepts an integer value as a parameter and that returns the index in the list of the last occurrence of that value, or 1 if the value is not found in the list....
-
Write a game that plays many rounds of Rock Paper Scissors. The user and computer will each choose between three items: rock (defeats scissors, but loses to paper), paper (defeats rock, but loses to...
-
The Koch snowflake is a fractal that is created by starting with a line segment, then recursively altering it as follows: 1. Divide the line segment into three segments of equal length. 2. Draw an...
-
Marsha Solomon, a physiotherapist, opened a practice. The business completed the following transactions: After these transactions, how much cash does the business have to work with? Use T-accounts to...
-
Refer to Exercise 2-3. Which of the transactions of Marsha Solomon, P.T., increased the total assets of the business? For each transaction, identify the asset that was increased or decreased....
-
Assume that Lululemon Athletica Inc. reported the following summarized data at December 31, 2020. Accounts appear in no particular order; dollar amounts are in millions. Prepare the trial balance of...
Study smarter with the SolutionInn App