Oh, I see. Well, there are several ways to do conditional code without using if statements.
The first way is to use the short-circuting feature of boolean logic. As you may be aware, with x && y, first x is tested. If it's false, the whole expression is false, no matter what the value of y, so y isn't even evaluated and the expression is given a value of false. If x is true, then y is evaluated. The expression is given a true value if y is true.
Usually one uses the value of the expression, like this:
But you can use it just like this:
if(x && y) do_something();
The easier way is to use the conditional operator, which is actually designed for this sort of thing. It's C and C++'s only tertiary operator, which means it takes not one or two but three expressions. ! takes one: if(!x). && takes two: if(x && y). But ?: takes three.
cout << "the difference is";
difference > 100 && cout << "much ";
cout << "greater than...";
The syntax for the conditional operator is this:
First, test is evaluated. If it's true, true-expression is evaluated; otherwise, it's false, and false-expression is evaluated.
(test) ? (true-expression) : (false-expression);
Usually the ?: operator is used in place of code like this:
where it's actually simpler to go
if(x > 100) y = 100;
else y = x;
But you can use it like this:
y = x > 100 ? 100 : x;
As you can see, the conditional operator works best when you have both a true-expression and a false-expression. If you don't you might as well use a boolean operator like && or ||.
cout << "difference is " << (difference > 100 ? "much " : "") << "greater than ...";