JirR02 b9d258de44 Exercise 2
Added Exercise 2 to repository
2025-03-01 13:38:33 +01:00
..
2025-03-01 13:38:33 +01:00
2025-03-01 13:38:33 +01:00

Task

Translate the following natural language expressions to C++ expressions. Assume that all the variables are non-negative integers or boolean (of value true or false).

For this task you need to write the solutions in the solutions.cpp file, by filling the various functions that have been defined for each subtasks.

Example: a is greater than 3 and smaller than 5. \Longrightarrow Solution:

return a > 3 && a < 5;

Note: Do not confuse the bitwise logical operators (e.g., &) with their binary logical counterparts (&&). The semantics are slightly different — bitwise operators do not exhibit short circuit evaluation.

  1. a greater than b and the difference between a and b is smaller than 15.
  2. a is an even natural number greater than a.
  3. a is at most 5 times greater than b (but can also be smaller than b) and at least 5 times greater than c.
  4. Either a and b are both false or c is true, but not both.
  5. a is false and b is zero.

Input

The program expects the task number as the first input followed by the parameters to the chosen task. For example, 3 5 1 1 selects task 3 with a = 5, b = 1, and c = 1.

Note that boolean parameters for tasks 4 and 5 are entered as true and false. For example 4 true false true would run task 4 with a = true, b = false, and c = true.