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++ → Introduction to C++ 40

What is the output: int x=6; cout<<(x&-x)<<' '<<(x/( x&-x));
2 3
click to copy
What is 'fold expression' with &&?
(args && ...) — true if all args are true
click to copy
What is the output: int x=0b11001100; cout<<__builtin_popcount(x);
4
click to copy
What is 'zero initialization'?
Setting memory to zero: 0 for scalars, null for pointers
click to copy
What is the output: cout<<__func__;
main
click to copy
What is 'string interning' concept?
Reusing same string object for equal strings
click to copy
What is the output: int x=10; cout<<(x&~(x-1));
2
click to copy
What is 'attribute [[nodiscard]]'?
Warns if return value is discarded
click to copy
What is the output: int x=3; cout<<(x<<1|1);
7
click to copy
What is 'likely' and 'unlikely' attributes in C++20?
Hints to compiler about branch probability
click to copy
What is the output: auto x=42u; cout<<sizeof(x);
4
click to copy
What is 'ODR-use'?
Using a variable/function in a way requiring its definition
click to copy
What is the output: int x=10; cout<<(x-=3)<<x;
77
click to copy
What is 'std::source_location' in C++20?
Provides file, line, function info at compile time
click to copy
What is the output: int x=5; int y=x; x=x^y; y=x^y; x=x^y; cout<<x<<y;
55
click to copy
What is 'memory order' in atomics?
Specifies synchronization strength of atomic operation
click to copy
What is the output: int x=5; cout<<(x+0.0==5.0);
1
click to copy
What is 'std::bit_cast' in C++20?
Reinterprets bits of one type as another safely
click to copy
What is the output: int x=255; cout<<(x&0xF)<<((x>>4)&0xF);
1515
click to copy
What is 'std::span' zero-overhead guarantee?
Non-owning view adds no allocation overhead
click to copy
What is the output: int x=5; cout<<(x^x^x);
5
click to copy
What is 'std::expected' in C++23?
Return type holding value or error without exceptions
click to copy
What is the output: int x=0; cout<<(x||1)<<(x&&1)<<(!x);
101
click to copy
What is 'CTAD' (Class Template Argument Deduction)?
Compiler deduces template args from constructor call (C++17)
click to copy
What is the output: cout<<(sizeof(int)==sizeof(int*));
0
click to copy
What is 'std::ranges' (C++20)?
Range-based algorithms operating directly on containers
click to copy
What is the output: int x=15; for(;x;x&=x-1) cout<<'1';
15
click to copy
What is 'std::format' in C++20?
Type-safe string formatting like Python's f-strings
click to copy
What is the output: int x=8; cout<<(x>0?x:x*-1);
8
click to copy
What is 'std::jthread' in C++20?
Auto-joining thread with stop token support
click to copy
What is the output: int x=5; cout<<(x*x-1)/(x+1);
4
click to copy
What is 'std::latch' in C++20?
Single-use countdown synchronization primitive
click to copy
What is the output: auto x=2; auto y=3; cout<<decltype(x+y)(10)/3;
3
click to copy
What is 'std::barrier' in C++20?
Reusable synchronization point where all threads must arrive
click to copy
What is the output: int x=100; cout<<(x&(-x)==x);
0
click to copy
What is 'std::counting_semaphore' in C++20?
Semaphore with configurable count for resource limiting
click to copy
What is the output: int x=7; cout<<(x|(x-1));
7
click to copy
What is 'std::stop_token' in C++20?
Mechanism for cooperative thread cancellation
click to copy
What is the output: constexpr int f(int n){return n<=1?1:n*f(n-1);} cout<<f(6);
720
click to copy
What is 'std::coroutine_handle'?
Low-level handle to resume/destroy a suspended coroutine
click to copy