do...while loop in C
Do...while loop is post-test loop or button-test loop.because it test the
loop condition at the top of the loop, the do...while loop in
C programming excute atleast one time whether the condition is true or false.
A do...while loop is similar to a while
loop, The do-while loop is mostly
used in menu-driven programs
Syntax
The syntax of a do...while loop in C
programming language is −
do {
statement;
} while( condition );
Flow chart:-
do...while loop in C |
Example:-
#include<stdio.h>
Void main()
{
Int a,i=1,f=1; //variable declaration int maens integer type variable
Printf(“\n Enter your Number:”);
Scanf(“%d”,&a);
//LOOP TO CALCULATE THE FACTORIAL OF A NUMBER
Do
{
F=f*I;
I++;
}while(i<=n);
Printf(“\n The Factorial of %d is %d”,n,f);
}
Factor of 12 |