C basics formulas
C fundamentals: types, operators, expressions and control flow. 4 formulas for GATE CS Programming in C, each with when to use it. Each is explained in the topic notes.
IAE Academy: C fundamentals: types, operators, expressions and control flow formulas (GATE CS)
All 4 C basics formulas
N-BIT INTEGER RANGES
Holds for any fixed-width integer type once its width in bits and its signedness are known. Use it to check whether a constant fits the type it is stored in.
STORING AN OUT-OF-RANGE VALUE V IN A SIGNED N-BIT TYPE
The standard leaves this conversion implementation-defined. On the two's complement machines these notes assume, the result is the value above. For example, 200 stored in a signed 8-bit char gives . An unsigned -bit type always stores , and that case is defined by the standard.
TWO'S COMPLEMENT NEGATION AND UNSIGNED WRAPAROUND
Here is the bitwise complement. Arithmetic done in unsigned int (or a wider unsigned type) never overflows in the undefined-behaviour sense: it is defined to wrap modulo . Signed overflow, such as INT_MAX + 1, is undefined behaviour. Converting an out-of-range value to a signed type is implementation-defined (see the storing rule in the previous section).
INTEGER DIVISION IDENTITY IN C
Holds for C integer operands when is representable. Truncation toward zero means that the sign of a % b follows the sign of a. Division or % by zero is undefined behaviour.
Where this was asked: 2018 (1), 2022 (1), 2024 (3), 2025 (2). See the 7 previous-year questions on C basics. This shows what was asked, not what will be asked.