while loop

View

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-

  1. while loop
  2. do-while loop
  3. for loop

while loop-

 Syntax-

                                                Initialization of loop variable
                                                while ( 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



Last modified: Tuesday, 21 September 2021, 9:44 AM