Starting from:
$35

$29

Lab #3 Solution

Description: Write a complete C program with additional functions as described below.

Part 1. [50pts] int find_max_distance(int num_inputs)

This function will read num_inputs integers from the console (assume the user enters only integers). It will find the maximum difference between two consecutive user entered numbers, and print and return the result. The function must contain a single loop.










Part 2. [50pts] void find_odd_average()

This function will read positive integers from the console (assume only integer inputs). It will read numbers until user enters -1. Your function will calculate the average of the positive odd numbers entered. The function must contain a single loop.









Notes:

You should have your main function calling these two functions properly. Make sure that the output formatting matches the given example.

Hints:
Use a counter in both functions to track the number of entries.

For part 1, use extra variables to keep track of the previous number entered and the current

maximum.

For part 2, use an extra counter for counting the odd numbers entered as well as an accumulator to keep track of their sum (which are at the end used for averaging).

What to hand in: A student with number 20180000001 should hand in ‘20180000001.c’.

More products