do-while







Do…while –loop
This statement is executed the body of the loop is will execute first.
The general form is

do
{
Body of loop
}
While(condition);
Next statement;




when this statement is executed the body of the loop will be executed first then the condition is evaluated. if the value will be true then the body of the loop will be executed.
if the value will be false then it will move to next statement.



Block diagram of do...while loop




example program:

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

void main()
{
int i=1;
do
{
printf("hello world!");
i++;
}
while(i<5);
getch();
}

youtube tutorial:


For-Loop

for statement is used to execute a statement or a group of statement for a known number of times.
the general form
for(control-variable;condition;increment/decrement)
{
body of the loop
}
next statement;


Comments

Popular posts from this blog

operators in c program

nested-if

switch-statement