While Loop in C Programming

  • While loop in C programming repeatedly executes statement as long as a given condition is true.
  •  The condition of the loop is tested before the body of the loop is executed.

Syntax

The syntax of While loop in C programming language is

While (condition)
{
   statement(s);
   Incrementation;
}

Flowchart of While loop in C programming

\"While
Flowchart-While Loop C Programming

For Example, C program of while loop that prints 1 to 10

#include<stdio.h>  
#include<conio.h>
int main()
{    
int i=1;      
while(i<=10){      
printf(\"%d \\n\",i);      
i++;      
}  
return 0;  
}    
Write a C Program to print table for the given number using while loop
#include<stdio.h> 
#include<conio.h> 
int main()
{    
int i=1,number=0;    
printf(\"Enter a number: \");    
scanf(\"%d\",&number);    
while(i<=10){    
printf(\"%d \\n\",(number*i));    
i++;    
}    
return 0;  
}