Tsallaka zuwa abun ciki
Justice Tech School

Operators

Arithmetic, comparison, logical and bitwise operators. Integer division drops the fraction.

Example
#include <iostream>

int main() {
  int a = 7, b = 2;
  std::cout << a / b << " " << a % b << " " << static_cast<double>(a) / b << "\n";
  std::cout << (a > b && b > 0) << " " << (a & b) << " " << (a << 1) << "\n";
  return 0;
}

Result

3 1 3.5
1 2 14

Exercise

Remainder.

7  2

Quiz Test

What is 7 / 2 for ints?

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