next up previous
Next: Example Up: Overview of C++ Previous: Example

If Statement

C++ if statement operates in much the same way that an IF statement operates in any other language. Its simplest form is

if (condition) statement; where
\begin{emph}
condition \end{emph}
is an expression that is evaluated to be either true or false. If the condition is true, then the statement will execute. If it is false, then the statement will not execute. The conditions are expressed using a rational operators which you can find in the following table (2.7)

 

 
Table 2.7: Rational Operators
Operator Meaning
> greater than
>= greater than or equal to
< less than
<= less than or equal to
== equal to
!= not equal to




 

Yousef Haik
2/23/1998