Branching Statement


        Branching Statement in C

Conditional Branching
The Conditional Branching Statement help to jump from one part of the program to another depending on whether a particular condition is satisfied or not.These desion control statement include:

1.Branching
2.Jumping
3.Looping


1.if statement
a.Simple if statement
b.if else statement
c.nested if statement
d.else if or ladder if
2.Switch statement





If Statement
The if Statement is the simplest form of decision control statement that is frequently use in decision making . It execute statement or set of statements when the logical condition is true the statement of if block are executed otherwise these statements will we skipped and the execution will jump to next statement.

Syntex:
if(condition)
statement;



If else statement
In the if else statement, first the test expression is evaluated.If the expression is true, statement block 1 is executed and statement block 2 is skipped.otherwise, if the expression is false, statement block 2 is executed and statement 1is ignore.

Syntex:
If (condition)
Program statement 1;
Else
Program statement 2;





Nested if Statement
It is an if statement that is the target of another if statement.Nested if statement means if statement inside of another statement.

Syntex:


if (condition1)
if (condition2)
statement-1;
else
statement-2;
else
statement-3;



Ladder if statement
The ladder if construct work in the same way as a normal if Statement.If is if construct is also known as nested if but in this if is statement is follow into the else part of the program.

Syntex:
if(condition1)
{
 //statements
} 
else if(condition2)
{
 //statements
}
else if(condition3)
{
 //statements
}
else
{
 //statements
}






Switch statement
A switch case statement is a multiway decision statement that is a simplified version of and if else block that evaluate only one variable.
The switch case statement compairs the value of the variable given in the switch statement with the value of each case statement that follows.When the value of the switch and the case  statement matches, the statement block of that particular case is executed.





Syntex:
switch (expression)
{
case 1:
statement;
break;
case 2: 
statement;
break;
___
___
___
case n:
statement n;
break;
default:
statement;
}


👉  Education is the passport
to the future, for tommorow belongs to those who prepare                    for it today. ðŸ‘ˆ

                Thank You

                 ðŸ˜‰ðŸ˜‰ðŸ˜‰
                       ðŸ™‹
                     

Comments

Popular posts from this blog

Introduction of C Language

Constant in C

Computer generation