Home / MCQ Bank / Computer
Computer Plus Plus Miscellaneous

What will be the output of the following C++ code? #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; }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option A • 2.72 12.15 72.25

Related Computer Questions

What is the difference between a shallow copy and a deep copy in Python? Which attribute is used to define a route in ASP.NET MVC? How to show the same presentation continuously? What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int var = -12; try { cout<<"Inside try\n"; if (var < 0) { throw var; cout<<"After throw\n"; } } catch (char var ) { cout<<"Exception Caught\n"; } cout<<"After catch\n"; return 0; } This type of query summarizes large amounts of data in easy-to-read, row-and-column format.