While loop: Execute a block of instructions repeatedly until the condition is false. We use while loop only when don’t know the number of iterations to do.
Syntax:
while(condition)
{
statements;
}
Flow Chart

Program to display digits of number in reverse order:
int main() { int n; printf(“Enter num : “); scanf(“%d”, &n); while(n!=0) { printf(“%d \n”, n%10); n=n/10; } return 0; } |
Program to count the digits in given number:
int main() { int n, count=0; printf(“Enter num : “); scanf(“%d”, &n); while(n!=0) { n=n/10; count++; } printf(“Digits count : %d \n”, count); return 0; } |