You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2. Write a pl/sql program to find SUM OF EVEN INTEGERS
DECLARE
num NUMBER(3) :=2;
sum1 NUMBER(4) :=0;
BEGIN
WHILE num <=5 LOOP
dbms_output.Put_line(num);
sum1 := sum1 + num;
num := num +2;
END LOOP;
dbms_output.Put_line('Sum of even numbers is '|| sum1);
END;
3. Write a pl/sql program to find GREATEST OF THREE NUMBERS USING IF ELSEIF
DECLARE
a NUMBER :=46;
b NUMBER :=67;
c NUMBER :=21;
BEGIN
IF a > b
AND a > c THEN
dbms_output.Put_line('Greatest number is '||a);
ELSIF b > a
AND b > c THEN
dbms_output.Put_line('Greatest number is '||b);
ELSE
dbms_output.Put_line('Greatest number is '||c);
END IF;
END;
4. Write a pl/sql program to find a number is ODD OR EVEN
DECLARE
n1 NUMBER := &num1;
BEGIN-- test if the number provided by the user is even
IF MOD(n1,2) =0 THEN
DBMS_OUTPUT.PUT_LINE ('The number. '||n1||' is even number');
ELSE
DBMS_OUTPUT.PUT_LINE ('The number '||n1||' is odd number.');
END IF;
DBMS_OUTPUT.PUT_LINE ('Done Successfully');
END;
5. Write a pl/sql program to find a FACTORIAL OF A NUMBER
DECLARE
num NUMBER := #
factorial NUMBER :=1;
BEGIN
FOR i IN1..num LOOP
factorial := factorial * i;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Factorial of '|| num ||' is '|| factorial);
END;