Ask Question
31 August, 15:07

Write a fragment of code that opens a file named numbers. txt, reads in pairs of number until end of file and sends the smaller of the two to a file named min. txt and the larger of the two to a file named max. txt (one number per line). You can assume there are no ties. (basic file input/output)

+1
Answers (1)
  1. 31 August, 17:37
    0
    See explaination for code

    Explanation:

    int x, y;

    ifstream numbers;

    numbers. open ("numbers. txt");

    ofstream min;

    min. open ("min. txt");

    ofstream max;

    max. open ("max. txt");

    while (numbers>>x>>y)

    {

    if (x>y)

    {

    max<
    min<
    }

    else

    {

    max<
    min<
    }

    }

    numbers. close;

    min. close;

    max. close;
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a fragment of code that opens a file named numbers. txt, reads in pairs of number until end of file and sends the smaller of the two ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers