WHILE LOOP

In C programming, a while loop is used to repeatedly execute a block of code as long as a specified condition is true. The syntax for a while loop in C is as follows:

while (condition) {

    // code to be executed while the condition is true

    // ...

}

Here, condition is a boolean expression. The code inside the curly braces will be executed repeatedly as long as the condition is true. Once the condition becomes false, the loop will exit, and the program will continue with the next statement after the while loop.

This code is to print number b/w 1 to 100

#include<stdio.h>

void main()

{

  int i=1;

  while(i<=100)

{

  printf(“%d/n”,i);

  i=i+1;

}

}

This code is to print table of 2

#include<stdio.h>

void main()

{

  int i=1;

  while(i<=10)

{

  printf(“2*%d=%d/n”,I,2*i);

  i=i+1;

}

}

This code is to print table of 2 in reverse order

#include<stdio.h>

void main()

{

  int i=10;

  while(1>0)

{

  printf(“2*%d=%d/n”,I,2*i);

  i=i-1;

}

}