← Back to Streams
Question 654
Count Reads Until Failure
Count Reads Until Failure
The program below writes5 10 15intonumbers.txtand opens it for reading with anfstream. Complete the loop so that it keeps reading integers intonwith>>and incrementscountfor every successful read. Then printRead N numbers, where N is the count, followed by a newline. The program must print exactly the output shown in Expected Output.
Expected Output:
Read 3 numbers= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Streamsfstream
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.