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++ 16

What is the output: int x=5,y=3; cout<<gcd(x,y)<<' '<<lcm(x,y);
1 15
click to copy
What is 'std::views::repeat' (C++23)?
Creates infinite or bounded range of repeated value
click to copy
What is the output: cout<<(1ull<<63);
9223372036854775808
click to copy
What is 'std::format_to' vs 'std::format'?
format_to writes to output iterator; format returns string
click to copy
What is the output: string s; format_to(back_inserter(s),"{:05d}",42); cout<<s;
00042
click to copy
What is 'std::views::cartesian_product' (C++23)?
Yields all combinations from multiple ranges
click to copy
What is the output: auto v=vector{1,2,3,4,5}; auto r=v|views::filter([](int x){return x%2==0;})|views::transform([](int x){return x*x;}); for(int x:r) cout<<x<<' ';
4 16
click to copy
What is 'std::views::join_with' (C++23)?
Joins range of ranges with delimiter
click to copy
What is the output: consteval int sq(int x){return x*x;} cout<<sq(7);
49
click to copy
What is 'std::generator<T>' usage?
co_yield values lazily in a coroutine function
click to copy
What is the output: int x=0; for(auto i:{1,2,3,4,5}) x+=i; cout<<x;
15
click to copy
What is 'std::move_sentinel' in C++20?
Sentinel adapter that allows move-only sentinel types
click to copy
What is the output: int x=5; string s=format("{:b}",x); cout<<s;
101
click to copy
What is 'std::ranges::iota' (C++23)?
Both A and B
click to copy
What is the output: auto v=views::iota(1,6)|views::transform([](int x){return x*x;}); cout<<ranges::fold_left(v,0,plus<>{});
55
click to copy
What is 'std::ranges::fold_left' (C++23)?
Both A and B
click to copy

OOP Using C++ → Variables and Data Types 24

What is the output: int x=5; decltype(x) y=10; cout<<sizeof(y);
4
click to copy
What is the output: auto x=1; auto y=2u; cout<<(x+y);
3
click to copy
What is 'std::integral_constant'?
Compile-time constant value as a type
click to copy
What is the output: constexpr auto x=1<=>2; cout<<(x<0);
1
click to copy
What is the output: int x=5; auto y=static_cast<double>(x)/2; cout<<y;
2.5
click to copy
What is 'std::type_identity'?
Identity type trait: type_identity<T>::type = T
click to copy
What is the output: int x=1000000; long long y=x*x; cout<<y;
Undefined behavior
click to copy
What is the output: string s="abc"; s.reserve(100); cout<<s.size()<<' '<<s.capacity();
3 100
click to copy
What is 'std::to_chars' vs 'std::to_string'?
to_chars: no allocation, faster; to_string: allocates string
click to copy
What is the output: char buf[10]; auto [ptr,ec]=to_chars(buf,buf+10,42); *ptr=0; cout<<buf;
42
click to copy
What is 'std::from_chars'?
Parses number from char buffer without locale/allocation
click to copy
What is the output: int x; from_chars("123","123"+3,x); cout<<x;
123
click to copy
What is 'std::remove_cvref_t'?
Removes const, volatile, and reference from type
click to copy
What is the output: cout<<is_same_v<remove_cvref_t<const int&>,int>;
1
click to copy
What is 'std::type_traits is_trivially_destructible'?
True if destructor is trivial (no user-defined dtor)
click to copy
What is the output: cout<<is_trivially_destructible_v<int><<is_trivially_destructible_v<string>;
10
click to copy
What is 'std::common_type'?
Deduces common type of multiple types
click to copy
What is the output: cout<<is_same_v<common_type_t<int,double>,double>;
1
click to copy
What is 'std::is_aggregate'?
True if type is aggregate (no user-provided ctor, no private/protected)
click to copy
What is the output: struct A{int x,y;}; cout<<is_aggregate_v<A><<is_aggregate_v<string>;
10
click to copy
What is 'std::underlying_type'?
Gets underlying integer type of enum
click to copy
What is the output: enum class E:uint8_t{A,B,C}; cout<<sizeof(underlying_type_t<E>);
1
click to copy
What is 'std::aligned_storage'?
Aligned raw storage for placement new
click to copy
What is 'std::is_layout_compatible'?
True if two types have same memory layout (C++20)
click to copy