Looping statements are used to execute a block code zero or more times. Looping statements are also known as iterative statements. C programming language supports the following looping statements:
- while
- do-while
- for
while - loop has test the condition first if it is true than executes the body until condition becomes false.
Syntax:
while(condition){
statement(s);
}
Example:
statement(s);
}
#include<stdio.h>
int main() {
int i = 1;
while(i<=5){
printf("Hello Govardhan\n");
i++;
}
return 0;
}
Output:
int main() {
int i = 1;
while(i<=5){
printf("Hello Govardhan\n");
i++;
}
return 0;
}
Hello Govardhan
Hello Govardhan
Hello Govardhan
Hello Govardhan
Hello Govardhan
Hello Govardhan
Hello Govardhan
Hello Govardhan
Hello Govardhan