Write Numbers 1 to 5
easyQuestion 599Write a function void writeNumbers(const string& filename) that opens filename with an ofstream and writes the integers 1, 2, 3, 4 and 5, one number per line (each followed by a newline). The starter opens the stream as out and provides the loop for (int i = 1; i <= 5; i++).
The test reopens the file and prints every line, so the output is exactly what is shown in Expected Output.
Do NOT write a main function.
Expected output
1 2 3 4 5 1 2 3 4 5
= newline. The output ends with a newline, so print one after the last line.
Hints2 available
Sign in to use hintsTopics
Streamsofstream
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.