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............. 

Jump statement

Welcome friends in my new post here we going to study about jump statement...........

Jump statement:

A jump statement transfers control from one place to another without checking any condition.There are four types of jumps statements-
  • break
  • continue
  • goto
  • return

Break:

The break statement takes control out of the current block.
syntax- break;


                          A break statement can appear only with a switch case body or any looping statement body.If it is placed anywhere else in the program.We get the compiler time error. break statement terminate enclosing switch or nearest enclosing. Loop the execution resumes with statement presents with next to the terminated loop or switch statement.

Continue:

continue statement are used when we require skipped a part of block or statement and again start executing from the beginning of the block.
syntax: continue;
Continue statement appears only inside body of loop.

goto lable:

The goto statement is used to branch unconditionally from one point to another. There can be more goto for a single lable but there cannot be two or more lable identifiers. Lable identifiers statement responding to single lable statement.
syntax:
main()
{
statement 1;
statement 2;
goto lable;
statement 1;
statement 2;
label;
statemenr 1;
statement 2;
}

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............. 

Thank you,
return statement will be explained in main function,
for learn C language read my every post from starting and when you have any problem please comment below.

Comments

Post a Comment

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