Page 1 of 1

Apply the CH language in accessing and using the command line arguments. You are asked to implement a C++ program that r

Posted: Sat Nov 27, 2021 2:34 pm
by answerhappygod
Apply The Ch Language In Accessing And Using The Command Line Arguments You Are Asked To Implement A C Program That R 1
Apply The Ch Language In Accessing And Using The Command Line Arguments You Are Asked To Implement A C Program That R 1 (39.21 KiB) Viewed 60 times
Apply the CH language in accessing and using the command line arguments. You are asked to implement a C++ program that reads from the command line some integers to compute their mean, variance and standard deviation. Your program should do the followings: (a) Read in the values from the command line. Allocate a dynamic memory location large enough to store the values in an array. Note that the number of values in the command line determines the size of the array. Display the values similar to the sample output below: There are 7 integers in the command line. 61 48 79 54 89 35 (6 marks) 56 (b) c) Calculate the mean where mean= Ex/n. Using the above example, mean = (61 + 48 + 79 + 54 + 89 + 35 + 56)/7 = 60.2857. (4 marks) Compute the variance and standard deviation where variance = (x - mean)2/n and standard deviation is the square root of variance. Using the above example, variance = ((61 - 60.2857)2 + (48 - 60.2857)2 + (79 - 60.2857)2 + (54 - 60.2857)2 + (89 - 60.2857)2 + (35 - 60.2857) + (56 - 60.2857) 2) / 7 = 289.061 standard deviation = sqrt(289.061) = 17.0018 (Note: sqrt() is the C++ function for calculating square root). (6 marks) Display the result of the calculation i.e. the mean, variance and standard deviation. A sample out is shown below. (d)