While loop



While the loop first checks whether the initialize condition is true or false and finding to be true, it will enter the loop and execute a corresponding code. Syntax of while loop is given below:- 

 

Syntax   

while (condition) 

{ 

    increment/  

    decrement. 

} 

 

Flowchart  

 

 

 

Program  



#include <stdio.h> 
#include <conio.h> 
void main() 
    clrscr(); 
    int a, i; 
    printf("enter a value of a: "); 
    scanf("%d", &a); 
    i = 0
    while (i<=a) 
    { 
        printf("%d \n", i); 
        i++; 
    } 
    getch(); 

output  

enter a value of a: 10 

0 

1 

 

 

 

 

 

 

 

 

10 


Follow our page for regular updates.

0 Comments