if ........................ else statement
The syntax is
if (expression)
statement set 1;
else
statement set 2;
The bracket contains a condition, the condition is tested, if the condition is true then statement set 1 gets executed and statement set 2 ignored.
If the condition is false then statement set 2 gets executed and statement set 1 is ignored.
Note that :-
1) Statement set 1 is called as the "if block" and statement set 2 is called as "else block"
2) else should be written below if.
3) Both the statement sets 1 and 2 should be written little towards the right side. This is the formatting convention.
4) Both the statement set should be enclosed in a pair of braces { } but braces are not required in case of single statement.
5) Both the statement sets must end with semicolon ;
if (expression)
statement set 1;
else
statement set 2;
The bracket contains a condition, the condition is tested, if the condition is true then statement set 1 gets executed and statement set 2 ignored.
If the condition is false then statement set 2 gets executed and statement set 1 is ignored.
Note that :-
1) Statement set 1 is called as the "if block" and statement set 2 is called as "else block"
2) else should be written below if.
3) Both the statement sets 1 and 2 should be written little towards the right side. This is the formatting convention.
4) Both the statement set should be enclosed in a pair of braces { } but braces are not required in case of single statement.
5) Both the statement sets must end with semicolon ;
0 comments:
Post a Comment