if and statement
Syntax
The
if statement
controls conditional branching. The body of an if statement is executed
if the value of the expression is nonzero. The syntax for the if
statement has two forms.
Syntax
if ( expression
)
statement
if ( expression
)
statement
else
statement
In
both forms of the if statement, the expressions, which can have any
value except a structure, are evaluated, including all side effects.
In
the first form of the syntax, if expression is true (nonzero), statement
is executed. If expression is false, statement is ignored. In the
second form of syntax, which uses else, the second statement is
executed if expression is false. With both forms, control then passes
from the if statement to the next statement in the program unless one of
the statements contains a break, continue, or goto.
The
following are examples of the if statement:
if ( i > 0 )
y = x / i;
else
{
x = i;
y = f( x );
}
No comments:
Post a Comment