Feed Headline Animator

Explain the “if” statement

The “if” statement: -

The “if statement” is used to execute a set of statements after testing a condition. The “if statement” evaluates the condition. If the given condition is true, the statement (or a block of statements) following the “if statement” is executed. If the condition is false, the statement (or block of statements) following the “if statement” is ignored and the control transfers to the statement immediately after the if structure.

The syntax of the “if statement” is:
If (condition)
Statement - 1;
Statement - 2;
In the above syntax, statement -1 will be executed if the given condition is true. If the given condition is false, statement - 1 is ignored and statement - 2 will be executed.
The execute a block of statements following the “if statement” the block of statements is enclosed in curly, i.e. within {}.
The syntax of “if statement” for executing a block of statements is:
If (condition)
{
Statement - 1;
Statement - 2;
Statement - 3;
}


Posted by: Wasim Javed

No comments:

Post a Comment