While loop in C

While loop is also known as pre-tested loop. In while loop has one control condition and they can execute as long they can condition is true. In the condition of the loop is tested before the body of the loop is executed.

Syntax of the while loop in C language

while(condition){
//code to be executed
}

Example of the while loop in C language

#include<stdio.h>  
int main(){    
int i=1;      
while(i<=10){      
printf("%d \n",i);      
i++;      
}  
return 0;  
}

Output

1
2
3
4
5
6
7
8
9
10

Submit your review
1
2
3
4
5
Submit
     
Cancel

Create your own review

The Technical Funda
Average rating:  
 0 reviews