Question: In C++, Write a program to read from a file that contains a list of floating numbers, load all floating numbers into an array, and
In C++, Write a program to read from a file that contains a list of floating numbers, load all floating numbers into an array, and calculate their average based on the array, and append the average to the end of the input data file. Users specify the file name.Use the given data provided to test your numbers. The size of data is known which will be 100, so you can simply declare an array of 100 doubles to hold all the floating numbers and solve this problem.
data:
42.579956382082 -71.770844026428 58.480963683631 -3.7379241451042 -94.894540347573 22.296631213126 7.4371065029345 -93.964359223718 -19.886832850536 -7.7293603459287 50.340095476734 78.50393795808 55.694971950136 89.1980453251 -99.187245341917 -57.183162981642 -74.409700336751 52.853942635729 31.84006953879 77.602956492161 37.792553920008 64.267474547145 32.451488600267 90.135377719614 -4.8691932507213 -50.871116876837 -59.061539609929 23.321936201617 36.517282081588 13.105279667932 70.390738713995 68.090599658552 35.343779599093 99.019687512903 -41.344532940828 -55.662865072009 20.448565038493 -83.362674123926 25.679836258109 -97.022780732206 -54.487644802115 -70.292409730105 94.738029804783 -76.41758150447 -7.9012688934046 -49.074911476971 55.293326786868 6.1478865544157 57.845016062916 79.178309008197 -56.461797249065 -62.833938164094 -54.203687734924 -75.882568426234 68.630191088888 23.098592140399 34.424558940864 -82.191941434867 53.931141697461 -81.36386989457 77.123526657124 80.594910012931 80.988441918258 82.455217609755 -86.785276813846 -24.444519296723 52.96332285651 44.442280888194 59.299676095104 -73.775814963924 -42.169583161925 39.064819677512 -86.796751148301 -19.912416425843 77.432375556739 -3.9359437759219 86.973709305947 57.139539440491 94.669967629088 53.420419574094 -0.60987797233881 -2.6705532127421 91.408590226114 97.663727827252 81.513863060539 77.637588034277 -19.189229906349 39.024732076899 -14.879295491227 12.820767061787 -39.627333156792 -15.910406360323 -9.6079286756012 37.66232603236 -38.918544370864 -82.177052407709 -97.12472024898 -95.246657322423 54.294971363642 -9.1992595095733
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
