Chapter 12 : Swift Decision Making Statement



Sometimes in coding we need to make a decision, such decisions are made using decision making structures.

We have below decision making structures

if statement : It consists of a boolean expression either true or false. We can use if statement one after another for multiple condition handling.

if else statement : It contain either if (if bool is true) or else (if bool is false)

if..elseif statement : If we have multiple condition , and need to check all one by one , and either of them is full filled then we need this statement. We can test various condition using this statement.

Nested if statement : Nested means here to use one if – else inside another one to check various condition.

switch statement :  Switch condition is used to check case according to switch variable value.

conditional operator : It works like if-else statement but using operators

syntax :  ? : operator

Expression1 ? Expression 2 : Expression 3 ;

Explain :

If Expression1 is true then execute Expression2

If Expression1 is false then execute Expression3



Add a Comment

Your email address will not be published. Required fields are marked *