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.

OOP Using C++ → Arrays 35

What is the output: vector<int> v={1,2,3}; v.push_back(4); v.insert(v.begin(),0); cout<<v.size()<<v[0];
50
click to copy
What is the output: int a[]={1,2,3,4,5}; cout<<*min_element(a,a+5);
1
click to copy
What is the output: int a[4]={4,3,2,1}; sort(a,a+4); cout<<a[0]<<a[3];
14
click to copy
What is the output: vector<int> v={1,2,3,4,5}; v.erase(remove_if(v.begin(),v.end(),[](int x){return x%2==0;}),v.end()); cout<<v.size();
3
click to copy
What is the output: int a[3][2]={{1,2},{3,4},{5,6}}; cout<<a[2][0]+a[0][1];
7
click to copy
What is the output: int a[]={3,1,4,1,5,9,2,6}; sort(a,a+8); cout<<a[4];
5
click to copy
What is the output: int a[]={1,2,3,4,5}; for_each(a,a+5,[](int x){cout<<x*x;});
149 1625
click to copy
What is the output: int a[]={1,2,3,4,5}; cout<<count_if(a,a+5,[](int x){return x>3;});
2
click to copy
What is the output: vector<int> v={5,3,8,1,9,2}; nth_element(v.begin(),v.begin()+2,v.end()); cout<<v[2];
5
click to copy
What is the output: int a[]={1,3,5,7,9}; cout<<*lower_bound(a,a+5,6);
7
click to copy
What is the output: deque<int> d; for(int i=1;i<=5;i++) d.push_front(i); cout<<d[0]<<d[4];
51
click to copy
What is the output: int a[]={2,4,6,8,10}; cout<<reduce(a,a+5,1,multiplies<int>());
3840
click to copy
What is the output: int a[5]={1,2,3,4,5}; reverse_copy(a,a+5,ostream_iterator<int>(cout));
54321
click to copy
What is 'std::mdspan' in C++23?
Multi-dimensional span for contiguous data
click to copy
What is the output: int a[]={1,2,3,4,5}; auto it=find_if_not(a,a+5,[](int x){return x<4;}); cout<<*it;
4
click to copy
What is the output: int a[5]={1,2,3,4,5}; copy_if(a,a+5,ostream_iterator<int>(cout),[](int x){return x%2!=0;});
135
click to copy
What is the output: vector<int> v={1,2,3,4,5}; cout<<*max_element(v.begin(),v.end());
5
click to copy
What is the output: int a[]={1,2,3,4,5}; cout<<equal(a,a+5,a);
1
click to copy
What is the output: int a[]={1,2,3}; int b[]={1,2,3}; cout<<equal(a,a+3,b);
1
click to copy
What is the output: int a[]={1,2,3,4,5}; cout<<mismatch(a,a+5,a+1).first-a;
0
click to copy
What is the output: int a[]={1,2,3,4,5}; adjacent_difference(a,a+5,a); for(int x:a) cout<<x;
11111
click to copy
What is the output: int a[5]={0}; generate_n(a,5,[n=1]()mutable{return n++;});cout<<a[4];
5
click to copy
What is the output: vector<int> v={1,2,3,4,5}; rotate(v.begin(),v.begin()+3,v.end()); cout<<v[0]<<v[4];
14
click to copy
What is the output: int a[]={1,2,3,4,5,4,3,2,1}; sort(a,a+9); cout<<*upper_bound(a,a+9,3);
4
click to copy
What is the output: int a[]={1,2,3,4,5}; cout<<transform_reduce(a,a+5,0,plus<>(),[](int x){return x*x;});
55
click to copy
What is the output: int a[3][3]={{1,2,3},{4,5,6},{7,8,9}}; cout<<a[0][2]+a[2][0];
10
click to copy
What is the output: int a[]={10,20,30}; cout<<*max_element(a,a+3)-*min_element(a,a+3);
20
click to copy
What is the output: int a[]={1,2,3,4,5}; cout<<inner_product(a,a+5,a,0,plus<>(),minus<>());
0
click to copy
What is the output: int a[]={5,3,8,1,4}; partial_sort(a,a+3,a+5); cout<<a[0]<<a[1]<<a[2];
138
click to copy
What is the output: vector<int> v={1,2,3,4,5}; cout<<accumulate(v.begin(),v.end(),1,multiplies<int>());
120
click to copy
What is 'std::ranges::views::filter'?
Lazy view filtering elements by predicate
click to copy
What is the output: int a[]={1,2,3,4,5}; cout<<*find_if(a,a+5,[](int x){return x*x>10;});
4
click to copy
What is the output: string s="hello"; reverse(s.begin(),s.end()); cout<<s;
olleh
click to copy
What is the output: int a[]={1,2,3,4,5}; cout<<accumulate(a,a+5,0,[](int s,int x){return s*10+x;});
12345
click to copy
What is the output: array<int,4> a={4,3,2,1}; sort(a.begin(),a.end()); cout<<a.front()<<a.back();
14
click to copy

OOP Using C++ → Pointers 5

What is the output: int a=5,b=10; int *p=&a; *p=*p+b; cout<<a;
15
click to copy
What is the output: int *p=new int(10); auto sp=shared_ptr<int>(p); auto sp2=shared_ptr<int>(p); cout<<sp.use_count();
Undefined behavior
click to copy
'What is the output: int a[]={1,2,3}; int *p=a+1; cout<<*( (1, 6, 77, 7, 4, 'What is the output: int x=5; int *p=&x; int **pp=&p; **pp=20; cout<<x;', 'Double pointer write?', '20', '20', '5', '5', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', '**pp=*p=x=20. Output: 20.', 0, '2026-05-25', '2026-05-25'), (1, 6, 77, 7, 4, 'What is the output: int a[]={10
30}; int *p=&a[2]; cout<<*p<<*(p-1)<<*(p-2);', 'Pointer from end: *p
click to copy
What is the output: int x=5; int *p=&x; int **pp=&p; **pp=20; cout<<x;
20
click to copy
What is the output: int a[]={10,20,30}; int *p=&a[2]; cout<<*p<<*(p-1)<<*(p-2);
302010
click to copy