Ask Question
Yesterday, 11:33

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. Yesterday, 12:25
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers