Control flow

4.6 - Boolean operators


Boolean operator works on truth values (true and false). The boolean operators are:

  • AND (&&)
  • OR (||)
  • NOT (!)

Example usage:

if (true && true) {
    // This will run because true and true equals true.
}

if (!true) {
    // This will not run because the negation of true is false.
}

Task

Write a program that takes a year number and prints out "leap year" if the number is either:

  • Divisible by 4 but not divisible by 100.
  • Divisible by 400.

Sample input

2000

Sample output

leap year
#include <iostream> int main() { // Start your program here }