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
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