if (testcondition)
{
statement (s);
}
else
{
statement (s);
}
Here, when the
testcondition
is true, the statements enclosed in the
if clause
are executed;
otherwise, statements enclosed in the
else clause
are executed.
The
if statement
is used to create a decision structure which allows a program to have more than
one path of execution. It can be represented by the flowchart in
Figure 2.1
.
Figure 2.1:
If-Else Decision Structure Logic Flowchart
Relational operators like >, <, >=, <=, = =, and != may be used.
Do'stlaringiz bilan baham: