Question: (5 pts) Draw a flowchart for an algorithm that finds the average of the digits in a 0 or positive integer number. For example, if
(5 pts) Draw a flowchart for an algorithm that finds the average of the digits in a 0 or positive integer number. For example, if the given integer is 522, then the average is (5 + 2 + 2) / 3 = 3. If the given integer is 1840, then the average is (1 + 8 + 4 + 0) / 4 = 3.25. 2. (2 pts 1 pt for return type, 1 pt/parameter) Provide the prototype for a function called avg_digits() that accepts one integer and returns the average of the digits in the number. 3. (8 pts 1 pt for the function header, 6 pts for algorithm, 1 pt for return value) Provide the function definition for avg_digits(). Also, be sure to provide the function header for avg_digits(). Precondition: input integer must be >= 0.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
