Skip to content
Justice Tech School

Operators

Arithmetic: + - * / %. Shortcuts: += -= ++ --. Comparison: == != < > <= >= give 1 (true) or 0 (false). Logical: && || !. Remember: = assigns and == compares.

Example
int x = 10;
x += 5;
x++;
printf("%d\n", x);
printf("%d\n", 17 % 5);
printf("%d %d\n", x > 10, x == 3);
printf("%d\n", (x > 10) && (x < 20));

Result

16
2
1 0
1

Exercise

Compare for equality.

if (a  b)

Quiz Test

What does = do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.