Use the if....else statement to execute some code if a condition is true and another code if the condition is not true.
Syntax
if (condition)
{ code to be executed if condition is true } else { code to be executed if condition is not true } |
Example
|
If...else if...else Statement
Use the if....else if...else
statement to select one of several blocks of code to be executed.
Syntax
if (condition1)
{ code to be executed if condition1 is true } else if (condition2) { code to be executed if condition2 is true } else { code to be executed if condition1 and condition2 are not true } |
Example
|
No comments:
Post a Comment
Type Your Comments........