Ask 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 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)

+3
Answers (1)
  1. 19 October, 07:01
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers