Question
Write a C-program that calculates the average of doubles. Your program will prompt the user for the value of double in a loop. The loop
Write a C-program that calculates the average of doubles. Your program will prompt the user for the value of double in a loop. The loop needs to terminate if the user decides there are no more numbers to enter. The user does not know how many numbers are there in total, so your allocated must grow as the user decides to enter more numbers.
At first, allocate run-time memory for one double only and obtain the value of the double from the user. In the loop, use the realloc() function to increase the memory allocated. Keep growing your memory and reading new double values as long as the user wants to enter new numbers. For every entry, you need to update the sum and the average of the values entered by the user, and display the updated average.
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