adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <cmath>
    #include <list>
    using namespace std;
    bool same_integral_part (double first, double second)
    {  
        return ( int(first) == int(second) ); 
    }
    struct is_near 
    {
        bool operator() (double first, double second)
        { 
            return (fabs(first - second) < 5.0); 
        }
    };
    int main ()
    {
        double mydoubles[] = { 12.15,  2.72, 73.0,  12.77,  3.14, 12.77, 73.35, 72.25, 15.3,  72.25 };
        list<double> mylist (mydoubles, mydoubles + 10);
        mylist.sort();
        mylist.unique();
        mylist.unique (same_integral_part);
        mylist.unique (is_near());
        for (list<double> :: iterator it = mylist.begin(); it != mylist.end(); ++it)
            cout << ' ' << *it;
        cout << '\n';
        return 0;
    }

a.

2.72 12.15 72.25

b.

12.15 73.0 12.77

c.

73.35

d.

None of the mentioned

Answer: (a).2.72 12.15 72.25

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?