WHILE LOOP IN C
In while loop the condition is tested first and then the statements are executed if the condition turns out to be true.
A while loop is never execute if its test condition would be false.
Example 1: Program To Print Counting 1 - 10
#include<stdio.h>
#include<conio.h>
void main
{
int a=1;
while(a <=10)
{
printf(“\n%d”,a);
a=a+1;
getch();
}
Example 2: Program To Print Reverse Counting 10 - 1
----------------------------
OUTPUT
----------------------------
10
}
Example 2: Program To Print Reverse Counting 10 - 1
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10;
#include<conio.h>
void main()
{
int a=10;
do
{
printf(“\n%d”,a);
a=a+1;
}
while(a >=1);
getch();
}
while(a >=1);
getch();
}
OUTPUT
----------------------------
10
9
8
7
6
5
4
2
0 Comments