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

Looping part 1

Hello guys, today we are going to start looping..........

Looping:

Looping means that a sequence of statement are executive until some conditions found false.
A program loop therefore consist of two parts-
  • Control statement
  • Body of loop
                     The control statement test certain conditions and then directs the replaced execution of the statement contain in the body of the loop.Looping structures are classified depending upon following categories -
  1. Depending upon position of control statement or test expression.
  2. Depending upon control variable portion.
  3. Depending upon looping process.

Counter Control loop:

           We use special variable called counter.In this type of loop the no. of  times the loop will execute is known in advance.
There are three loops in C programming-
  • while loop
  • for loop
  • do-while loop

1. While loop:

Simplest form of looping is while loop. It is the entry control loop because the test expression is checked while entering the loop.

Syntax:

while ( test expression ) 
{
  body of  loop;
}

                                    The test expression can be a expression a constant value or a variable. The body of loop is executed till the test expression remains true and as it becomes false the control is transferred out of the loop.

Steps:

  1. Declare the control variable or loop variable.
  2. Initialized the control variable.
  3. Form the test condition then found the body of the loop modify the loop variable.
Ex.
#include<stdio.h>
main()
{
int i=1;
while(i<=10)
{
printf("%d \n ",i);
i++;
}
printf("End of program");
}

This is example of while loop here we show how while loop works.
for hindi explain of looping see my another post.
Thank you,
Keep supporting 
for any query 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