if-else statement

 

if-else statement:

 The simple if statement is expanded upon by the if-else statement.If the condition is true, the body of the if statement in this sentence is executed; otherwise, the body of the else statement is.Only the control goes to the following statement after either the body of if or the body of otherwise is executed in this statement.


The general syntax of if-else statement is

Flowchart:


Ex:


In the above example if value of 'a' is greater than 'b' then value of 'a' is the output otherwise value of 'b' is the output. 


Comments