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 and Looping statement part 1

                       C programming


Decision control and looping statements:

Introduction:

The decision control statements are the decision making statements that decides the order of execution of statements based on the conditions. In the decision making statements the programmer specify which conditions are to be executed or tested with the statement to be executed if the condition is true or false.

Conditional Branching statement:

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 decision control statement statement include -
  • if statement 
  • if else statement
  • if else if statement
  • switch statement

 if statement:

The if statement is the simplest form of the simplest from of the decision control statement.
This is frequently used in decision making.

syntax:

if ( test expression )
{
statement 1;
--------------
-------------
statement n;
}
statement x;

if else statement:

In i else statement there are two type of sentence we write if first will not be true second will be true.

syntax:

if(test expression)
{
    statement block 1;
}
 else
{
    statement block 2;
}
statement x;

thank you,

remaining conditional statement will be cover in next post;

please ask your doubt...........


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