Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

Data Structures and Algorithms → Introduction to DSA 18

The output of: multiset<int> ms={1,2,2,3,3,3}; cout<<ms.count(3);
3
click to copy
The output of: multimap<int,string> mm; mm.insert({1,"a"}); mm.insert({1,"b"}); mm.insert({2,"c"}); cout<<mm.count(1);
2
click to copy
The output of: int x=42; const int &cr=x; x=100; cout<<cr;
100
click to copy
The output of: const int x=5; int *p=const_cast<int*>(&x); *p=10; cout<<x;
5 (modifying const is UB)
click to copy
The output of: class A{public:void f()const{cout<<"const";}void f(){cout<<"non-const";}}; const A a; a.f();
const
click to copy
The output of: class A{public:void f()const{cout<<"C";}void f(){cout<<"N";}}; A a; a.f();
N
click to copy
The output of: int arr[5]; fill(arr,arr+5,7); cout<<arr[0]<<arr[4];
77
click to copy
The output of: vector<int> v={1,2,3}; v.assign(5,0); cout<<v.size()<<v[0];
50
click to copy
The output of: list<int> l={1,2,3,4,5}; l.remove(3); cout<<l.size();
4
click to copy
The output of: list<int> l={3,1,4,1,5}; l.sort(); l.unique(); cout<<l.size();
4
click to copy
The output of: vector<int> v={1,2,3,4,5}; auto r=remove_if(v.begin(),v.end(),[](int x){return x%2==0;}); v.erase(r,v.end()); cout<<v.size();
3
click to copy
The output of: forward_list<int> fl={1,2,3}; fl.push_front(0); cout<<fl.front();
0
click to copy
forward_list vs list in C++:
forward_list is singly-linked (no backward traversal, less memory)
click to copy
The output of: auto r=views::iota(1,6)|views::transform([](int x){return x*x;})|views::take(3); for(auto x:r)cout<<x<<" ";
1 4 9
click to copy
The output of: int n=2; while(n<=100){cout<<n<<" "; n*=2;}
2 4 8 16 32 64
click to copy
The output of: int arr[]={1,2,3,4,5}; int*p=arr+2; cout<<*(p-1)<<*p<<*(p+1);
234
click to copy
The output of: string s="Hello World"; istringstream iss(s); string word; vector<string> words; while(iss>>word)words.push_back(word); cout<<words.size()<<words[0];
2Hello
click to copy
C++ is best described as which type of programming language?
Compiled, statically-typed, multi-paradigm language supporting OOP, generic, and procedural programming
click to copy