Question: Question 5 ( 2 0 marks ) A program written to calculate the mean of three input data from the user which is listed as
Question marks
A program written to calculate the mean of three input data from the user which is listed as below:
#include
void mainvoid
float value value value total mean;
printf This program takes in three data ;
printf and calculate the mean.
; Introduction
printf Enter data no : ; Prompt user
scanf f &value; Get the first data
total total value; Obtain the total
printf Enter data no : ; Prompt user
scanf f &value; Get the second data
total total valuel; Obtain the total
printf Enter data no : ; Prompt user
scanf f &value; Get the third data
total total value; Obtain the total
mean total ; Calculate the mean
printf The mean is f
mean;
End of program
Program
Analyze Program in detail and answer the following questions:
ai State the data type used by all the variables in Program
marks
ii Explain two drawbacks of the method used in Program to collect data.
iii Explain the purpose of initializing the variable total.
b Modify Program to take in any number of input data and calculate the mean from the input data.
Use array to store the input data.
The number of input data is determined by the user, with maximum up to data.
Use the preprocessor directive: #define to set the maximum number of input data at
The program needs to check whether the number of input data keyed in by the user exceeds the maximum allowable size or not, which is Write a function for this purpose, which can be called from the main function.
Use loop to repeatedly collect the input data from the user and store them in the array.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
