Question
Design and write a C++ program to read in a file of integers and process the list. The input file should be named data.txt. The
Design and write a C++ program to read in a file of integers and process the list. The input file should be named "data.txt". The first line of the file is how many integers are contained in the rest of the file. The remainder of the file will have one integer per line. You must use the new operator to dynamically allocate storage for the list of numbers. You must also use the delete operator to deallocate the storage when you are done with the list.
Once the numbers have been read into memory from the file, your program will manipulate the list with three functions that all take a pointer parameter. The functions perform the following operations:
- Find the mean of the list - returns a floating point number
- Determine if a specific number is the list - returns a boolean
- Count how many numbers in the list are even - returns an integer
All three of the required functions require one parameter, the pointer to the list. You may need additional parameters to your functions.
The output of your program will be:
- the number of integers in the list,
- the mean of the list,
- the existence of a specific number (prompt the user for a number to find), and
- the number of even numbers in the list.
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