adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <memory>
    #include <algorithm>
    using namespace std;
    int main ()
    {
        int numbers[] = {1, 5, 4, 5};
        pair <int*, ptrdiff_t> result = get_temporary_buffer<int>(4);
        if (result.second > 0)
        {
            uninitialized_copy (numbers, numbers + result.second, result.first);
            sort (result.first, result.first + result.second);
            for (int i = 0; i < result.second; i++)
                cout << result.first[i] << " ";
            return_temporary_buffer (result.first);
        }
        return 0;
    }

a.

1 5 5 4

b.

5 5 4 1

c.

1 4 5 5

d.

1 4 5 2

Answer: (c).1 4 5 5

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?