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 -
- Depending upon position of control statement or test expression.
- Depending upon control variable portion.
- 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:
- Declare the control variable or loop variable.
- Initialized the control variable.
- 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.
Sir plz looping hindi long expln
ReplyDelete