WHILE Loop in C Language

WHILE Loop in C Language:

(1) The while statement executes a block of code repeatedly as long as the control condition of the loop is true. The control condition of the while loop is executed before any statement inside the loop is executed.

(2) Sample C language code and its output, as shown:

Sample C language code for while loop
#include <stdio.h>
#include <conio.h>
//Table of 2 using for loop
int main()
int x;
i = 0;
  x = 1;
while (x <= 10)
i = i + 2;
printf(“2 * %d = %d \n”,x,i);
return 0;

(3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.

click on build for while loop code in C

(4) After building the code, press the “Run” button, as shown.

run the while loop code in C

(5) After pressing the “run” button, the output screen is opened, as shown.

For loop code ouput obtained in c

while Loop Syntax:

while (condition) {
  //write logic

FOR Loop in C Language
while Statement (C)– Microsoft Docs
Use of UPPER Function in SQL

Leave a Reply