ITERATIVE
STATEMENTS
The While Statement
The while statement or while loop is
an open-ended or event controlled
loop. The while loop iterates while
the condition is TRUE (1). When it
becomes FALSE (0), the program
control passes to the line after the
loop code.
The General form of the while
statement is:
While (condition)
{
statement_sequence;
}
The DO-WHILE statement
The second type of open-ended or
event controlled loop is the do-
while.
Statement or do While loop.
The General Form of the do-while
statement is:
do
{
Statement_sequence;
}
while (condition);
While
Write a program that will print the
numbers 1 to 10 using while while
statement.
Do-while
Write a program that will get the
average of all intregers from 1 to 10
using do-while loop.

iterarative statements.pptx

  • 1.
  • 2.
    The While Statement Thewhile statement or while loop is an open-ended or event controlled loop. The while loop iterates while the condition is TRUE (1). When it becomes FALSE (0), the program control passes to the line after the loop code.
  • 3.
    The General formof the while statement is: While (condition) { statement_sequence; }
  • 4.
    The DO-WHILE statement Thesecond type of open-ended or event controlled loop is the do- while. Statement or do While loop.
  • 5.
    The General Formof the do-while statement is: do { Statement_sequence; } while (condition);
  • 6.
    While Write a programthat will print the numbers 1 to 10 using while while statement.
  • 7.
    Do-while Write a programthat will get the average of all intregers from 1 to 10 using do-while loop.