C Plus Plus Miscellaneous - Study Mode

[#741] What will be the output of the following C++ code? #include <iostream>
#include <algorithm>
using namespace std
bool myfn(int i, int j)
{
return i < j
}
int main ()
{
int myints[ ] = {3, 7, 2, 5, 6, 4, 9}
cout << *min_element(myints, myints + 7, myfn) << '
'
cout << *max_element(myints, myints + 7, myfn) << '
'
return 0
}
Correct Answer

(A) 2 9

[#742] What is the syntax of swap()?
Correct Answer

(B) arr1.swap(arr2)

[#743] What will be the output of the following C++ code? #include <iostream>
#include <complex>
using namespace std
int main()
{
complex <double> cn(3.0, 4.0)
cout<<"proj"<<cn<<" : "<<proj(cn)<<endl
return 0
}
Correct Answer

(A) proj(3,4) : (3,4)

[#744] What will be the output of the following C++ code? #include<iostream>
using namespace std
int main()
{
int a = 5
auto check = [&]()
{
a = 10
}
check()
cout<<"Value of a: "<<a<<endl
return 0
}
Correct Answer

(B) Value of a: 10

[#745] What will be the output of the following C++ code? #include <iostream>
#include <deque>
using namespace std
int main ()
{
deque<int> mydeque (5)
deque<int>::reverse_iterator rit = mydeque.rbegin()
int i = 0
for (rit = mydeque.rbegin()
rit!= mydeque.rend()
++rit)
*rit = ++i
for (deque<int> :: iterator it = mydeque.begin()
it != mydeque.end()
++it)
cout << ' ' << *it
return 0
}
Correct Answer

(C) 54321