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++ → Variables and Data Types 40

What is the output: int x=0; cout<<(x?'T':'F');
F
click to copy
What is 'value category' in C++?
lvalue/prvalue/xvalue: classifies expressions
click to copy
What is the output: long long x=1234567890123; cout<<x;
1234567890123
click to copy
What is 'std::numeric_limits<float>::epsilon()'?
Smallest float difference from 1.0
click to copy
What is the output: int x=5; auto y=x; auto& z=x; z=10; cout<<x<<y;
105
click to copy
What is 'integer literal suffix'?
L/LL/U/UL/ULL specifying type of literal
click to copy
What is the output: int x=10; double y=3; cout<<x/y;
3.33333
click to copy
What is 'structured binding' for struct?
auto [x,y]=myStruct; binds members to names
click to copy
What is the output: float f=1.0f/0.0f; cout<<isinf(f);
1
click to copy
What is 'std::monostate'?
Empty type usable as first variant alternative
click to copy
What is the output: int x=5; cout<<(x%2==0?"even":"odd")<<' '<<x;
odd 5
click to copy
What is 'std::optional::value_or'?
Returns value if present, else default
click to copy
What is the output: int x=1000; char c=x; cout<<(int)c;
Impl-defined
click to copy
What is 'extended precision' floating point?
80-bit x87 FPU format used on x86
click to copy
What is the output: auto x=0x1p4; cout<<x;
16
click to copy
What is 'thread_local' storage?
Each thread has own instance of the variable
click to copy
What is the output: int x=5; auto f=[x]()mutable{x+=5; return x;}; cout<<f()<<x;
105
click to copy
What is 'union' size?
Size of largest member
click to copy
What is the output: int x=5; cout<<typeid(x).name();
i
click to copy
What is 'std::complex' operations?
Arithmetic: +,-,*,/ all defined for complex<T>
click to copy
What is the output: int x=5; cout<<(x>0)*x+(x<0)*(-x);
5
click to copy
What is 'NaN' in floating point?
Not a Number: result of undefined operations like 0.0/0.0
click to copy
What is the output: double x=0.0/0.0; cout<<(x==x);
0
click to copy
What is 'consteval if' in C++23?
if consteval: true branch when in constant evaluation context
click to copy
What is the output: int x=10; cout<<(x>>1)<<(x&1);
50
click to copy
What is 'std::in_place_t'?
Tag type for in-place construction in optional/variant
click to copy
What is the output: int x=INT_MIN; cout<<(x<0);
1
click to copy
What is 'deduction guide for std::pair'?
pair(T,U)->pair<T,U> enables CTAD
click to copy
What is the output: unsigned x=10; int y=-1; cout<<(x+y);
9
click to copy
What is 'std::byte to integer' conversion?
std::to_integer<int>(b) — explicit conversion
click to copy
What is the output: char c='a'; c-=32; cout<<c;
A
click to copy
What is 'std::variant::index()'?
Returns index of currently held type
click to copy
What is the output: int a=5,b=3; cout<<max({a,b,a+b,a*b});
15
click to copy
What is 'scoped enum' (enum class)?
Enum values scoped to enum name; no implicit int conversion
click to copy
What is the output: enum class E{A=1,B=2,C=4}; cout<<(int)E::C;
4
click to copy
What is 'std::any::type()'?
Returns type_info of stored value
click to copy
What is the output: int x=5; int y=10; cout<<min(x,y)<<max(x,y);
510
click to copy
What is 'constexpr variable'?
Compile-time constant value
click to copy
What is the output: double x=1.5; int y=x; cout<<y;
1
click to copy
What is 'std::clamp' in C++17?
Clamps value to [lo,hi] range
click to copy