While loop Assignment Help

Assignment Help: >> Iterative Control - While loop

While loop:

The while loop statement associate a condition with a sequence of statements enclosed by the keywords LOOP and END LOOP. Syntax of the WHILE LOOP is given below.

Syntax

While condition loop

Sequence_of_statements;

END LOOP;

The condition is evaluated before each iteration of the loop. If the condition becomes TRUE, the sequence of statements is executed and the control resumes at the top of the loop. If the condition becomes FALSE or NULL then the loop is bypassed and control passes to the next statement after end loop. The given example shows the total of the first 20 numbers by using the WHILE LOOP statement.

Example

DECLARE

X integer:=1;

Yinteger:=0;

BEGIN

WHILE x < = 20

LOOP Y:=Y+x; X:=X+1;

END LOOP;

DBMS_OUTPUT.PUT_LINE(Y);

END;

In the given example, the loop is executed only when the while condition is fulfilled.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd