....

February 1, 2021

Scope of If-statement

if is a conditional statement, which returns true or false based on the condition that is passed in it’s expression.

By default, if-statement is implemented on only one line, that follows it.
But if we put block after the if-statement, it will be implemented on the whole block.

Syntax_1:
if(expression)
statement

In the above example, if-statement will be implemented on only statement.

Syntax_2:
if(expression)
{
statement1
statement2
…………….
}

In above example, if-statement will be implemented on the whole block, to all the statements that would be present there.

Note: Same happens with else too.

by : Erfan Adil

Quick Summary:

if is a conditional statement, which returns true or false based on the condition that is passed in it’s expression. By default, if-statement is implemented on only one line, that follows it. But if we put block after the if-statement, it will be implemented on the whole block. Syntax_1: if(expression) statement In the above example, […]