This statement is also used for decision making. Here key word is switch followed by control variable and followed by it’s block.In the block of switch statement multiple cases are used and each ends with break statement this is also called as early exit loop.Out of all the cases only that case will run whose value matches with the control variable.
This statement can be used to select any one statement or a block which contains a set of instructions. Only that statement will execute which is true according to the data entered and rest other conditions will not executed.
This statement is also a conditional statement. It starts with keyword ‘if’ followed by an expression followed by “ first statement” and “ second statement” is given after ‘else’ clause.
Format:if(expression)statement1;elsestatement2;
It is used whenever any condition is to be implemented by the user it means some conditions like:1. If the price of the item is more than 5000 then discount is 10%.2. If the students marks are greater than 60% then he should be in 1st division.
This statement is also used for decision making. Here key word is switch followed by control variable and followed by it’s block.
In the block of switch statement multiple cases are used and each ends with break statement this is also called as early exit loop.
Out of all the cases only that case will run whose value matches with the control variable.
This statement can be used to select any one statement or a block which contains a set of instructions. Only that statement will execute which is true according to the data entered and rest other conditions will not executed.
FORMAT:
if(expression1)
Statement1;
else if(expression2)
statement2;
else if(expression3)
statement3;
This statement is also a conditional statement. It starts with keyword ‘if’ followed by an expression followed by “ first statement” and “ second statement” is given after ‘else’ clause.
Format:
if(expression)
statement1;
else
statement2;
It is used whenever any condition is to be implemented by the user it means some conditions like:
1. If the price of the item is more than 5000 then discount is 10%.
2. If the students marks are greater than 60% then he should be in 1st division.