Question: Lab 8 1 CMPSC 201-Fall 2015 CMPSC 121 Fall 2015 Lab 8 To be done individually Due by end of your class time on 11/2/17

Lab 8

1

CMPSC 201-Fall 2015

CMPSC 121 Fall 2015

Lab 8

To be done individually

Due by end of your class time on 11/2/17

Do not use any concepts beyond Chapter 7 of your textbook!

Goals:

Reading data from file, using arrays and functions.

Problem:

You are to read a series of floating point numbers from a text file store them in an

array, then calculate the average of the values in that array. Your program should employ 2

functions other than main.

The first function should open the file, store the values in an array, count and

return

the number

of values stored in the array to the function call.

The second function should calculate average of the values in the array and

return

the average

of the values to the function call.

The name of the text file is Lab8.dat (do not edit or change the name of the file).

Your main function should declare an array that could contain up to 400 floating point numbers,

call the function to read the values from the file, call the function to calculate the average value,

then output the number of values in the file and the average value in the file.

You may want to create a smaller file for testing.

Make sure that you have included your introductory comments containing the purpose of

the program i.e. what problem or task is being solved plus the input needed from user to

complete the problem/task, output expected from the program, and the processing needed

to get the output from the input. The description of the purpose should be detailed enough

that a person reading your code would not need any additional information to understand

the problem. The processing comments should not include any C++ commands.

Remember to confirm all your submissions to Canvas. You may make multiple

submissions to the same drop box and the last submission will be graded.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!