if Statement

 

if Statement:

The effective decision-making statement is the if statement. It is utilised to carry out the assertion and verify the condition. If the condition is true, this statement will only execute the body of the if statement; otherwise, control will move on to the following sentence. The result of this expression is true or false.
The general syntax of if statement is 


Flowchart:



The body of if statement  may have one statement or group of statement where each statement is separate by semicolon.

For ex:



In the above example the user put the value of 'a' and 'b' then control check the condition i.e a>b. If 'a' is greater than 'b' then the value of 'a' will be print otherwise it will exit from statement. 

Comments