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++ → Operators in C++ 18

What is the output: int a=1; cout << a (1, 6, 73, 3, 4, 'What does the 'delete' operator do when called on a null pointer?
Nothing (safe)
click to copy
What does the 'delete' operator do when called on a null pointer?
Nothing (safe)
click to copy
What is operator[] overloaded for in std::vector?
Unchecked element access by index
click to copy
What is the output: int x=0; cout<<(x=5)<<' '<<(x==5);
5 1
click to copy
What is the type of: sizeof expression?
size_t
click to copy
What is the output: int a=4,b=2; cout<<(a^=b,b^=a,a^=b)<<' '<<a<<' '<<b;
2 2 4
click to copy
What is the output: cout << (1 << 0) << ' ' << (1 << 1) << ' ' << (1 << 4);
1 2 16
click to copy
What is the output: bool a=true,b=false; cout<<(a&&b)<<(a||b)<<(!a);
010
click to copy
What does the :: operator do when used without a left-hand side?
Accesses global namespace
click to copy
What is the output: int x=5; cout<<x<<x++<<x;
Undefined behavior
click to copy
What is the output: int a=10; cout<<(a>5)+(a<20)+(a==10);
3
click to copy
Which operator is used for pointer-to-member access?
.*
click to copy
What is the result: int x = 5; x = x > 3 ? x + 1 : x - 1; cout << x;
6
click to copy
What is the output: int a = 5, b = 10; cout << (a < b ? a : b) * 2;
10
click to copy
What is the output: cout << 10/3*3;
9
click to copy
What does overloading operator= return by convention?
*this (reference to self)
click to copy
What is the output: int x = -5; cout << (x >> 1);
-3
click to copy
What is the output: int a=3,b=4; if(a=0) cout<<a; else cout<<b;
4
click to copy

OOP Using C++ → Control Statements 22

What is the output: for(int i=0;i<5;i++) if(i==3) continue; cout<<i;
Compile error
click to copy
What is the output: int x=10; switch(x){case 10: cout<<'A'; case 20: cout<<'B'; default: cout<<'C';}
ABC
click to copy
What does 'goto' do in C++?
Jumps to a labeled statement
click to copy
What is the output: int i=0; do{ cout<<i; i++; }while(i<0);
0
click to copy
What is the output: for(;;) { static int x=0; cout<<x++; if(x>2) break; }
012
click to copy
What is the output: int x=5; if(x>3) if(x>4) cout<<'A'; else cout<<'B';
A
click to copy
What is the output: for(int i=0;i<3;i++) for(int j=0;j<3;j++) if(i==j) goto done; done: cout<<'X';
X
click to copy
What is a 'range-based for loop' iteration over a raw array?
Iterates over each element
click to copy
What is the output: int x=5; while(x (1, 6, 74, 4, 4, 'What happens when break is used inside a nested loop?', 'Nested loop के अंदर break use करने पर क्या होता है?', 'Breaks out of all loops', 'सभी loops से बाहर निकलता है', 'Breaks out of innermost loop only', 'केवल innermost loop से बाहर निकलता है', 'Compile error', 'Compile error', 'Undefined behavior', 'undefined behavior', NULL, 'option_b', 'break only exits the immediately enclosing loop or switch; not outer loops.', 0, '2026-05-25', '2026-05-25'), (1, 6, 74, 4, 4, 'What is the output: switch(2.5){ case 2: cout<<'A'; break; default: cout<<'B'; }
Compile error
click to copy
What happens when break is used inside a nested loop?
Breaks out of innermost loop only
click to copy
What is the output: switch(2.5){ case 2: cout<<'A'; break; default: cout<<'B'; }
Compile error
click to copy
What is the output: for(int i=1; i<=4; i*=2) cout<<i<<' ';
1 2 4
click to copy
What is the output: int x=0; for(;x<5;) cout<<x++;
01234
click to copy
What does 'fallthrough' attribute do in C++17?
Suppresses warning about intentional fallthrough
click to copy
What is the output: int i=5; for(i=0; i<3; i++) {} cout<<i;
3
click to copy
What is the output: int x=1; if(x=0) cout<<'T'; else cout<<'F';
F
click to copy
What is the output of an infinite while(true) loop with no break?
Program hangs indefinitely
click to copy
What is the output: for(int i=0;i<5;i++) { if(i%2==0) continue; cout<<i; }
13
click to copy
What is the difference between while and do-while loops?
do-while executes body at least once
click to copy
What is the output: int x=3; switch(x) { case 1: case 2: case 3: cout<<'A'; break; default: cout<<'B'; }
A
click to copy
What is the output: int n=10; for(int i=2; i*i<=n; i++) if(n%i==0) { cout<<'C'; break; }
C
click to copy
What is the output: int x=0; while(x<3) { x++; if(x==2) break; } cout<<x;
2
click to copy