Question
Do it in C, fix the code, answer the questions and explain them in detail #include /* Read a set of values from the user.
Do it in C, fix the code, answer the questions and explain them in detail
#include /* Read a set of values from the user. Store the sum in the sum variable and return the number of values read. */ // You CANNOT declare any global variables // You CANNOT change the definition of the read_values function (e.g., add/remove function parameters, or change the return type) int read_values(double sum) { int values = 0, input = 0; sum = 0; printf("Enter input values (enter 0 to finish): "); scanf("%d", &input); while(input != 0) { values++; sum += input; scanf("%d", input); } return values; } int main() { double sum = 0; int values; values = read_values(sum); printf(" Average: %g ", sum/values); // Hint: How do we ensure that sum is updated here AFTER read_value manipulates it? return 0; }
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