Write a program (main) that reads 5 integers entered by the user and stores in an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program (main) that reads 5 integers entered by the user and stores in an array. The program calls average odds function to display the average of the odds, calls average evens function to display the average of the evens. Finally, the program calls compare function for the average of the odds (first argument) and the average of the evens (second argument). If compare. function returns true, it displays "The average of odd(s) is greater than the average of even(s)." message. Otherwise, it displays "The average of even(s) is less than the average of odd(s).". The program has three latter functions average odds, average_evens, and compare. Here are the prototypes for the latter three functions: float average odds(int arr[], int arr size); Calculates the average of the odd numbers in array arr. float average_evens(int arr[]); Calculates the average of the even numbers in array arr. bool compare(float first_num, float second_num); Compares two floating point number. If the first number is greater than second number, it returns true. If the second number is greater than first number, it returns false. Expected output of the program: Enter 5 numbers: 8 23 7165 The average of odd(s) : 33.0 The average of even(s) : 7.0 The average of odd(s) is greater than the average of even(s). Enter 5 numbers: 86 60 3 9 43 The average of odd(s) : 18.3 The average of even(s) : 73.0 The average of odd(s) is less than the average of even(s). PA Write a program (main) that reads 5 integers entered by the user and stores in an array. The program calls average odds function to display the average of the odds, calls average evens function to display the average of the evens. Finally, the program calls compare function for the average of the odds (first argument) and the average of the evens (second argument). If compare. function returns true, it displays "The average of odd(s) is greater than the average of even(s)." message. Otherwise, it displays "The average of even(s) is less than the average of odd(s).". The program has three latter functions average odds, average_evens, and compare. Here are the prototypes for the latter three functions: float average odds(int arr[], int arr size); Calculates the average of the odd numbers in array arr. float average_evens(int arr[]); Calculates the average of the even numbers in array arr. bool compare(float first_num, float second_num); Compares two floating point number. If the first number is greater than second number, it returns true. If the second number is greater than first number, it returns false. Expected output of the program: Enter 5 numbers: 8 23 7165 The average of odd(s) : 33.0 The average of even(s) : 7.0 The average of odd(s) is greater than the average of even(s). Enter 5 numbers: 86 60 3 9 43 The average of odd(s) : 18.3 The average of even(s) : 73.0 The average of odd(s) is less than the average of even(s). PA
Expert Answer:
Answer rating: 100% (QA)
C program include float averageoddsint arr int arrsize float averageevensint arr bool comparefloat f... View the full answer
Related Book For
Managers and the Legal Environment Strategies for the 21st Century
ISBN: 978-1111530631
7th edition
Authors: Constance E. Bagley
Posted Date:
Students also viewed these accounting questions
-
Input a number entered by the user and display "Positive" if it is greater than zero, "Negative" if it is less than zero, and "Zero" if it is equal to zero.
-
Write a user-defined function that calculates grade point average (GPA) on a scale of 0 to 4, where A = 4, A- = 3.7, B+ = 3.3, B = 3, B- = 2.7, C+ = 2.3, C = 2, C- = 1.7, D+ = 1.3 D = 1, and E = 0....
-
Write a program that displays all the prime numbers less than 120 in decreasing order. Use the StackOfIntegers class to store the prime numbers (e.g., 2, 3, 5,... ) and retrieve and display them in...
-
1. By integrating Planck's codiation law over all wave hengths power radiated per square meter of a is given by: R(T) = (55) T" proof that the cavity's surface note: x= he AKT 2 xdx 3 % ex-1
-
Many companies use long-term leases to finance long-term assets. Although these leases are similar to mortgage payments, they are structured in such a way that they qualify as operating leases. As a...
-
Consider a system modeled via the third-order differential equation Develop a state variable representation and obtain a block diagram of the system assuming the output is x(t) and the input is u(t)....
-
For a given x-value, the 95% confidence interval for the mean response will always be wider than the 95% prediction interval. In Exercises 5 and 6, determine whether the statement is true or false....
-
Shannons account at Commerce Bank has a balance of $1,200. Shannons account number is 1236. Requirement 1. Assuming the bank uses encryption for customer account numbers and the last digit is a check...
-
1. Estimate the balance of the Allowance for Doubtful Accounts using percent of sales method. Assume a $0 existing balance in Allowance for Doubtful Accounts. Hint. Identify the percent of...
-
Pennack Corporation purchased 75% of the outstanding stock of Shing Corporation on January 1, 2014 for $300,000 cash. At the time of the purchase, the book value and fair value of Shing's assets and...
-
1 pts LOS Ltd is an insurance agent and provides insurance advisory services to Mee Ltd. LOS Ltd receives a commission from the insurance company Ibis Ltd when LOS Ltd places Mee Ltd's insurance...
-
At December 31, 2020, the trading securities for Larkspur Company are as follows: Security Cost Fair Value A $20,160 $25,200 B 42,840 40,320 $63,000 $65,520 Prepare the adjusting entry at December...
-
It is currently winter in California, but the southern hemisphere is experiencing summer. Draw a sketch to explain why the seasons are different in the northern and southern hemispheres and state two...
-
Which affiliate marketing strategy do you think is the most effective? Why? Compare and contrast permission marketing, affiliate marketing, and viral marketing. Incorporate relevant examples to...
-
Focusing on Humanistic and Positive Psychology. Based on the reading "Positive Psychology: An Introduction" After reading browse the following Positive Psychology/Humanistic websites: The Journal of...
-
How do environmental globalization processes, such as climate change and transboundary pollution, challenge traditional frameworks for environmental governance and necessitate a more collaborative...
-
Question 4 Consider the production process with 2 inputs and 1 output. The production function is given by y = x The input prices are w, and w, respectively. Consider the case of long run where both...
-
9.Consider the reaction 3NO2(g)+H2O=2HNO3(aq)+NO(g) where Delta H=-137 kJ.How many kilojoules are released when 92.3g of NO2 reacts?
-
Who is a merchant? Does a customer waive the implied warranty of merchantability by examining goods before it purchases them?
-
Is a clause on the front of a seller's invoice that limits its liability to $25 enforceable?
-
Is a company a responsible party under CERCLA if another party spills waste that, without the fault of the first firm, flows onto its property?
-
Air passes through a normal shock in a supersonic wind tunnel. Upstream conditions are \(M_{1}=1.8, T_{1}=270 \mathrm{~K}\), and \(p_{1}=\) \(10.0 \mathrm{kPa}\) absolute. Downstream conditions are...
-
A Boeing 747 cruises at \(M=0.87\) at an altitude of \(13 \mathrm{~km}\) on a standard day. A window in the cockpit is located where the external flow Mach number is 0.2 relative to the plane...
-
Air flows isentropically through a converging nozzle into a receiver where the pressure is \(250 \mathrm{kPa}\) absolute. If the pressure is \(350 \mathrm{kPa}\) absolute and the speed is \(150...
Study smarter with the SolutionInn App