C data types, operators, control flow, functions, scope, storage classes and the compilation model. Excludes pointers and file I/O.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What are the four basic data types in C?
Show answer
int, char, float, double
- What is the difference between signed and unsigned integer types?
Show answer
Signed can represent negative values, unsigned cannot but has a larger positive range
- How do float and double differ in C?
Show answer
float is single-precision (32-bit), double is double-precision (64-bit) and more accurate
- How do you perform an explicit type cast in C?
Show answer
(type) value, for example (int) 3.14 or (float) x
- What keyword prevents a variable from being modified after initialization?
Show answer
const
- What is the modulo operator % used for?
Show answer
It returns the remainder of a division operation
- Name the three logical operators in C.
Show answer
&& (and), || (or), ! (not)
- What is operator precedence?
Show answer
The order in which operators are evaluated in an expression when no parentheses specify otherwise
- How does the ternary operator ?: work?
Show answer
condition ? value_if_true : value_if_false, it selects one of two values based on a condition
- What are compound assignment operators?
Show answer
+=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=, they combine an operation with assignment
- Name the six bitwise operators in C.
Show answer
& (and), | (or), ^ (xor), ~ (not), << (left shift), >> (right shift)
- What is the difference between = and ==?
Show answer
= is the assignment operator, == is the comparison operator (tests equality)
- What do the increment ++ and decrement -- operators do?
Show answer
They add or subtract 1 from a variable, respectively
- List the six relational operators in C.
Show answer
< (less than), > (greater than), <= (less or equal), >= (greater or equal), == (equal), != (not equal)
- Explain short-circuit evaluation with && and ||.
Show answer
With &&, evaluation stops once a false is found. With ||, evaluation stops once a true is found.