looping statement
looping statements
loop structure are used to execute a group of statements repeatedly until the condition is satisfied. They are
- While -loop
- Do…while-loop
- For-loop
While-loop
This will be a simple loop statement.
The general loop structure is
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
#include<conio.h>
void main()
{
int i =1;
while (i<=5)
{
printf(“hello world\n”);
i++;
}
getch();
}
youtube tutorial
Comments
Post a Comment