Question: Please help C++ The data.txt text file contains a number on the first line, n , followed by n lines with three names on each
Please help C++
The data.txt text file contains a number on the first line, n, followed by n lines with three names on each line as shown below:
4 Linda Adam Jo Bob Mina Clive John Xavier Dana Emily Katie Tim
Write a program to do the following:
- Open the file
- Read the number on the first line into variable n
- If n is 0 or negative
- display an error message of your choice.
- If n is 1 or above do the following:
- Read three names from the file into three variables
- Determine the name that would be last in alphabetical order (the largest)
- Display this name
- Repeat this process for all remaining lines
- Close the input file.
Expected output for the above example:
Linda Mina Xavier Tim
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
