See a problem in else if statement

Dangling else problem

Image
Hello, This problem comes when we use else if statement and do some mistake more describe is given below......... Dangling else problem: One of the major problem with nested if is dangling else problem. The problem arises when both outer if statement inner if statement might pair with common else statement. Thus the compiler is not able to judge to pair the else with which statement. The solution to this problem is given by the compiler that it pairs else with the recent if thus sometimes giving wrong result.                                           Hence the programmer should put early bracket wherever required. This post is may very short because my only aim was to describe this problem. Thank you, Keep supporting............. 

Decision control statement and looping statements part 2

                            C programming

This is the second part of decision control statement here we will discus remaining two part of statement.

if-else-if:

if-else-if statement is used to test additional conditions. This is also known as nesting if statement.her e if else if  continuesly comes ,first if else statement write than next if else will be start from first else in simple words if else statement when used inside any if else block.

Switch statement:

A witch statement is a multi-way decision statement that is a simplified version of an if -else-if block that evaluate only one variable.the general form of  switch statement shown in figure-

syntax:


switch (var)
{
case 1:
{
Statement 1;
break;
}
case 2:
{
Statement 2;
break;
 }
case 3:
{
Statement 3;
break;;
}
Statement n;
}



Thank you,
keep supporting,
If any doubt please comment below....................

Comments

Popular posts from this blog

Libraray Fine Hackerrank solution in C || Balanced Brackets Hackerrank solution in C

Permutations of Strings hackerrank solution in C || Permutations of Strings

Introduction to C part 2