0% found this document useful (0 votes)
13 views

Loop - Imprime Los Números Pares Hasta El 20: Declare Number Begin

The document contains 3 PL/SQL code snippets that use different looping structures: 1) A LOOP that prints even numbers from 2 to 20 using a counter variable and exit condition. 2) A FOR loop that prints numbers from 1 to 10 ascending and descending, summing the values. 3) A WHILE loop that prints subtraction and addition using counter variables until they are equal.

Uploaded by

Marco
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Loop - Imprime Los Números Pares Hasta El 20: Declare Number Begin

The document contains 3 PL/SQL code snippets that use different looping structures: 1) A LOOP that prints even numbers from 2 to 20 using a counter variable and exit condition. 2) A FOR loop that prints numbers from 1 to 10 ascending and descending, summing the values. 3) A WHILE loop that prints subtraction and addition using counter variables until they are equal.

Uploaded by

Marco
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

LOOP --imprime los nmeros pares hasta el 20

declare v_contador number(2):=2; begin dbms_output.put_line('Los numeros pares son:'); loop dbms_output.put_line(v_contador); exit when v_contador = 20; v_contador := v_contador+2; end loop; end;

FOR --imprime nmeros ascendente y descendente del 1 al 10


DECLARE a NUMBER := 1 ; b NUMBER := 10 ; suma NUMBER(2) := 0 ; suma2 NUMBER(2) := 0 ; BEGIN FOR i IN a..b LOOP suma := suma + i ; dbms_output.put_line('Ascendente: '|| i); END LOOP ; FOR j IN REVERSE a..b LOOP suma2 := suma2 + j ; dbms_output.put_line('Descendente: '|| j); END LOOP ; END;

WHILE --imprime la suma y resta


declare i number(2) := 4; j number(2) := 2; BEGIN WHILE i<>j LOOP i := i - 1; dbms_output.put_line('- '|| i); j := j + 1; dbms_output.put_line('+ '|| j); END LOOP; END ;

You might also like