Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Statistical Analysis of an Array The contents of an int array will be provided to you one Learning You can create and initialize an array
Statistical Analysis of an Array The contents of an int array will be provided to you one Learning You can create and initialize an array with those contents by using an array initialization list, as follows: intmainArr[]={//copyinarraycontentshere};Everyelementofthisarrayisanintbetween0and3000, exceptforthelastelement, whichis-1.Since we did not provide a size declarator in the array declaration, nordoweknowhowmanyelementsareinthearrayuntilweprocessit, thatlast-1canbeusedasasentinelvalueforourarrayprocessing.Itisnotconsideredpartofthedatasetinthearrayandshouldnotbeincludedinthefollowingcalculations.WriteaCprogramthatscansthroughthearraycontents(everythingexceptthe-1)and determines the following statistics on it: 1) the number of elements 2) the average of the elements 3) the minimum and maximum values 4) the second to last minimum and second to last maximum values (if the min or max values are duplicated, use the duplicated value not then next unique value) Your program should analyze the array, determine the above statistics, and printout there results in the following format. Total number: 700Average: 2462.9Minelement: 15Min2element: 21Maxelement: 2984Max2element: 2976 The average should be printed as a floating point value with one decimal position. All numbers should be right justified as indicated."Min2"refersto the second-to-smallest minimum element, and "Max2" refers to the second-to-largest maximum element. Note that it is not necessary to create an output file for this project. Printing there results to the console will be sufficient Please take the array for Program#4 and determine how many duplicate values there are the array and what their index positions are. The output should look like: Value1899was foundanindices: 1, 9. Value 1059 was found at indices: 20, 224, 475. Value 1607 was found at indices: 25, 120. Value 2535 was found at indices: 415, 488. Total Duplicates found: XX All of the indices for a given value are listed on one line. Your program should not have more than one entry for the same number. Only numbers that have at least one duplicate should be reported. Note that the meaning of a duplicate is "two numbers at different index positions that have the same value." This means that if a number appears n times in the array, there are a total of same value." This means that if a number appears n times in the array, there are a total of (n/2) = n times (n - 1)/2 duplicates for that number. Thus, if a number appears twice in the array, that contributes 1 duplicate to the total duplicate count. If a number appears 3 times, that contributes 3 duplicates. And if a number appears 4 times, that contributes (4 times 3)./2 = 6 duplicates to count
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started