I need help to complet this program: while-loop: end of file controlled while As
ID: 3617603 • Letter: I
Question
I need help to complet this program: while-loop: end of file controlled whileAssuming an input file stream, myIn, has been openedsuccessfully,
- Use the while loop to read all the numbers stored in file.
- After reading all the numbers, compute and print theiraverage.
- Do not use an array.
- It is possible that the file is empty, in which case theaverage is considered to be zero.
If the file contains 1, 2, 3, and 4, your algorithm should print2.5.
If the file contains 1, 2, and 3, your algorithm should print2.
If the file contains nothing, your algorithm should print0. use the following variables(myIn, average,count, number, sum) I need help to complet this program: while-loop: end of file controlled while
Assuming an input file stream, myIn, has been openedsuccessfully,
- Use the while loop to read all the numbers stored in file.
- After reading all the numbers, compute and print theiraverage.
- Do not use an array.
- It is possible that the file is empty, in which case theaverage is considered to be zero.
If the file contains 1, 2, 3, and 4, your algorithm should print2.5.
If the file contains 1, 2, and 3, your algorithm should print2.
If the file contains nothing, your algorithm should print0. use the following variables(myIn, average,count, number, sum)
Explanation / Answer
please rate - thanks #include #include using namespace std; int main() {double average; int count=0,number, sum=0; char filename[30]; coutfilename; ifstream myIn; myIn.open(filename); if(myIn.fail()) //is it ok? { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.