Largest Number in a File
mediumQuestion 584A text file contains one or more integers separated by spaces or newlines, for example:
12 91 5 44
Write a function int maxInFile(const string& filename) that opens the file, reads every integer with >> and returns the largest one. The file always contains at least one number, and numbers may be negative.
The test prints the returned value on its own line, for example (see Expected Output).
Do NOT write a main function.
Expected output
91 -3
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Streamsifstream
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.