C operators will feel familiar from Java: arithmetic, comparison, logical, and assignment. Watch integer division and operator precedence.
Arithmetic and assignment
int a = 7, b = 3;
int sum = a + b; /* 10 */
int quot = a / b; /* 2 — integer division truncates */
double exact = 7.0 / 3.0;
Increment and compound assignment
++i and i++ differ when their value is used in an expression. Prefer simple, readable forms while learning.
Logical operators
&&, ||, and ! return 0 or 1. C has no distinct boolean type unless you include stdbool.h.
Important interview questions and answers
- Q: Result of 5 / 2 in C?
A: 2 with integer operands—use floating literals for fractional results. - Q: Difference between = and ==?
A:=assigns;==compares. Accidental assignment in conditions is a classic bug.
Self-check
- What is 9 % 4?
- Does 3.0 / 2 produce an integer?
Interview prep
- Integer division trap?
7 / 3is 2, not 2.333—cast todoubleor use floating literals for fractional math.