Question 21
EasyWhat is the output of this program?
#include <iostream>
using std;
{
cout << ( >> );
;
}
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>
using std;
{
cout << ( >> );
;
}
5
101
1
20
Sign up free to see the answer and a step-by-step explanation.
Which header must be included to use cout and cin?
<stdio.h>
Sign up free to see the answer and a step-by-step explanation.
What does the line using namespace std; do?
Imports all C libraries
Makes the program run faster
Creates a new namespace called std
Lets you use names from the std namespace, such as cout, without writing std::
Sign up free to see the answer and a step-by-step explanation.
Which C++ keyword allocates memory for an object on the heap?
new
alloc
create
malloc
Sign up free to see the answer and a step-by-step explanation.
What does STL stand for in C++?
System Thread Library
Standard Text Layout
Standard Template Library
Simple Type Language
Sign up free to see the answer and a step-by-step explanation.
Which C++ container stores unique keys in sorted order?
std::unordered_set
std::vector
std::queue
std::set
Sign up free to see the answer and a step-by-step explanation.
In C++, how do you write a single-line comment?
-- comment
// comment
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <iostream>
#include <set>
using namespace std;
int main() {
set<int> s = {3, 1, 2, 3, 1};
for (int x : s) cout << x << " ";
return 0;
}
1 3 2
1 2 3
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<string, int> m;
m["banana"]++;
m["apple"]++;
m["apple"]++;
for (auto &p : m) cout << p.first << ":" << p.second << " ";
return 0;
}
banana:1 apple:2
apple:2
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;
template <typename T>
T add(T a, T b) { return a + b; }
int main() {
cout << add<int>(5, 10);
return 0;
}
5
10
Sign up free to see the answer and a step-by-step explanation.
3 2 1
2 3 1
apple:1 banana:1
apple:2 banana:1
15
Error