Question: Programming Instructions Write the program to incorporate the following requirements: Data to the program is input from a file of an unspecified length; that is,
Programming Instructions
Write the program to incorporate the following requirements:
- Data to the program is input from a file of an unspecified length; that is, the program does not know in advance how many numbers are in the file.
- Save the output of the program in a file.
- The input and output file should be opened in the function main.
- There should be a function getNumber which reads a number from the input file and sends the number read to the function main.
- Create a function which counts the number of numbers in the file, sums them, and finds the value of each number raised to the third power using the pow function in the cmath library.
- Write to the output file and to the screen each number read and the number to the third power. There should be one line per number read.
- At the end, the number of numbers in the input file and the sum of the numbers should be written to the screen and to the output file.
An example of the program's output file might look like the following:
20 8000
32 32768
2 8
-33 -35937
...etc...
The number of numbers in the file = 25
The sum of the numbers = 24638
Compile and run the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
