A condition is a yes/no question that your program asks about its data.
n even?" → yes or nox between 1 and 100?" → yes or noIn C++ the answer to such a question is a value of type bool: either true or false.
Syntax. A condition is any expression that produces true/false:
n % 2 == 0 // is n even?
x >= 1 // is x at least 1?
Think first. Before writing a condition, say the question out loud : "Is the number divisible by 3?" Then translate it to a boolean expression.
Without conditions, a program does the same thing for every input. Almost every problem needs the program to decide:
YES if ..., otherwise print NO."Simple example