Simple example on how while loop works.
Syntax:
while(condition) {}
Condition : A condition is assigned to tell while loop that till when it should continue its loop.
Example to print 10 even numbers.
#include<stdio.h>
int main()
{
int num = 0;
while(num <=10) //Repeat this block
{
if(num%2 == 0)
{
printf(" %d ",num);
}
num++;// This simply means num = num +1
}
return 0;
}
Output:
Description:
Description in marathi /เคฎเคฐाเค ीเคค เคตเคฐ्เคฃเคจ
Syntax:
while(condition) {}
Condition : A condition is assigned to tell while loop that till when it should continue its loop.
Example to print 10 even numbers.
#include<stdio.h>
int main()
{
int num = 0;
while(num <=10) //Repeat this block
{
if(num%2 == 0)
{
printf(" %d ",num);
}
num++;// This simply means num = num +1
}
return 0;
}
Output:
Description:
Description in marathi /เคฎเคฐाเค ीเคค เคตเคฐ्เคฃเคจ
Comments