while loop
Loops-
Sometimes we require executing same set of statements finite number of times. In such situation, we can use loops. Various types of loops available in C are-
- while loop
- do-while loop
- for loop
while loop-
Syntax-
Initialization of loop variablewhile ( condition using loop variable )
{
Statements (s);
Increment/decrement of loop variable;
}
A condition using loop variable is specified with while-statement. If the condition is FALSE then the statements inside while block will be skipped, If the condition is TRUE then the statements inside while block will be executed again and again until the condition becomes FALSE.
Example- Write a Program in C to print your name 10 times
Flowchart-
Flowchart- Example