Question
A file contains an unknown number of integers that may be positive, negative, or zero. Complete the following C++ program. THe program should read and
A file contains an unknown number of integers that may be positive, negative, or zero. Complete the following C++ program. THe program should read and process the input as follows.
- for each positive integer, compute the sum of its factors, then display the integer and the sum. -compute the exact average of the negative integers -continue reading and processing input until a 0 is encountered (read) -display the average of the negative integers.
Notes: There we be at least one zero in the file, but it may not be the last value in the file. Input will be read via Linux Redirection. The file will exist and not be empty.There will be at least one negative number in the file (do not check for division by 0). DO NOT USE SEPERATE FUNCTIONS.
Sample input file: 19 24 -3 18 11 -16 0 150 Sample output: Sum of the factors for 19 is 20 Sum of factors for 24 is 60 Sum of factors for 18 is 39 Sum of factors for 11 is 12 Average of negative numbers = -9.5 Part of the code: #include
}
}
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