Skip to content
Justice Tech School

Operators

Arithmetic: + - * / %. Shortcuts: += ++ --. Comparison: == != < > <= >=. Logical: && || !. Integer division drops decimals, so convert one side to double when you need a decimal result.

Example
int x = 10;
x += 5;
x++;
cout << x << endl;
cout << 17 % 5 << endl;
cout << 7 / 2 << " " << 7 / 2.0 << endl;
cout << (x > 10 && x < 20) << endl;

Result

16
2
3 3.5
1

Exercise

Which operator gives the remainder?

17  5

Quiz Test

What is 7 / 2 with two ints?

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