`int` — C++ Keyword
`int` — C++ Keyword
The int keyword in C++: the natural signed integer type for the platform.
`int` — C++ Keyword
The int keyword in C++: the natural signed integer type for the platform.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
intThe natural signed integer type for the platform, guaranteed to be at least 16 bits but typically 32 bits on all modern architectures.
int n;
int n = 42;
unsigned int u = 42u;
long int l; // int suffix is optional
#include <print>
#include <climits>
int main() {
int a = 10, b = 3;
std::println("{}", a + b); // 13
std::println("{}", a / b); // 3 (truncated integer division)
std::println("{}", a % b); // 1 (remainder)
std::println("min: {} max: {}", INT_MIN, INT_MAX);
// min: -2147483648 max: 2147483647 (on 32-bit int platforms)
// Overflow is undefined behavior for signed int
// int overflow = INT_MAX + 1; // UB!
}
int is the default type for integer literals and the result of most arithmetic expressions.std::int32_t / std::int64_t when exact width matters.intint main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}