Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program (main) that reads 5 integers entered by the user and stores in an array. The program calls average odds function to
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
C program include float averageoddsint arr int arrsize float averageevensint arr bool comparefloat f...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