Question 61
HardWhat is the output of this program?
#include <iostream>
#
std;
{
vector<> v = {, , , , , };
v.((v.(), v.(), []( x) { x % == ; }), v.());
cout << v.() << << v.();
;
}
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Programming Languages
What is the output of this program?
#include <iostream>
#
std;
{
vector<> v = {, , , , , };
v.((v.(), v.(), []( x) { x % == ; }), v.());
cout << v.() << << v.();
;
}
3 5
6 6
0 5
3 6
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
unordered_map<string, int> m;
for (string w : {"a", "b", "a", "c", "a", "b"}) m[w]++;
cout << m["a"] << m["b"] << m["c"] << m.size();
return 0;
}
3213
3212
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
map<int, string> m{{3, "c"}, {1, "a"}, {2, "b"}};
auto it = m.lower_bound(2);
cout << it->second << m.begin()->first << prev(m.end())->second;
return 0;
}
c1b
a1c
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
priority_queue<int> pq;
for (int x : {4, 9, 1, 7}) pq.push(x);
priority_queue<int, vector<int>, greater<int>> mn;
for (int x : {4, 9, 1, 7}) mn.push(x);
cout << pq.top() << mn.top();
return 0;
}
91
19
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string s = "hello world";
reverse(s.begin(), s.begin() + 5);
cout << s << " " << count(s.begin(), s.end(), 'l');
return 0;
}
olleh world 3
hello world 3
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
using namespace std;
int main() {
int a = 5;
auto f = [a]() mutable { a += 10; return a; };
cout << f() << " " << f() << " " << a;
return 0;
}
15 25 25
15 25 5
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector<int> v{3, 1, 4, 1, 5, 9, 2, 6};
nth_element(v.begin(), v.begin() + 3, v.end());
cout << v[3];
return 0;
}
1
4
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
using namespace std;
int main() {
int x = 10;
int &r = x;
int *p = &r;
*p = 20;
r++;
cout << x;
return 0;
}
11
20
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> v(3, 7);
v.resize(5);
v.push_back(1);
cout << v.size() << v[4] << v[0];
return 0;
}
507
6 07
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
#include <string>
#include <tuple>
using namespace std;
int main() {
pair<int, string> p{2, "two"};
auto [n, s] = p;
tuple<int, char, double> t{1, 'x', 2.5};
cout << n << s << get<1>(t) << get<2>(t);
return 0;
}
2twox2
2twox2.5
Sign up free to see the answer and a step-by-step explanation.
3214
1113
b3a
b1c
41
97
dlrow olleh 3
olleh world 2
15 15 15
15 15 5
3
5
10
21
607
617
two2x2.5
2two1x