looping statement





looping statements
loop structure are used to execute a group of statements repeatedly until the condition is satisfied. They are
  1.    While -loop
  2. Do…while-loop
  3. For-loop





While-loop
This will be a simple loop statement. 

The general loop structure is
While(condition)
{
body of the loop;
}
Next statement;

When the statement is executed then it will checks the condition is false or not? If it is false then move to next statement or it is true then the loop body will be execute. When the condition becomes false then the control is transferred to next statement




Flowchart :





Example code for c program

#include<stdio.h>
#include<conio.h>

void main()
{
int i =1;
while (i<=5)
  {
    printf(“hello world\n”);
    i++;
  }
getch();
}
youtube tutorial








Do…while –loop


This statement is executed the body of the loop is will execute first.

The general form is




Comments

Popular posts from this blog

operators in c program

nested-if

switch-statement