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
DECLARE
fahrenheit NUMBER;
celsius NUMBER;
BEGINDBMS_OUTPUT.PUT('Enter temperature in Fahrenheit: ');
fahrenheit := &fahrenheit;
celsius := (fahrenheit -32) *5/9;
DBMS_OUTPUT.PUT_LINE('Temperature in Celsius: '|| celsius);
END;
2. Write a pl/sql program to find SUM OF EVEN INTEGERS
DECLARE
sum NUMBER=0;
BEGIN
FOR i IN1..10 LOOP
IF i MOD 2=0 THEN
sum = sum + i;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Sum of even integers from 1 to 10: '|| sum);
END;
3. Write a pl/sql program to find GREATEST OF THREE NUMBERS USING IF ELSEIF
DECLARE
a NUMBER := &a;
b NUMBER := &b;
c NUMBER := &c;
max NUMBER;
BEGIN
max := a;
IF b > max THEN
max := b;
END IF;
IF c > max THEN
max := c;
END IF;
DBMS_OUTPUT.PUT_LINE('The greatest of '|| a ||', '|| b ||', and '|| c ||' is '|| max);
END;
4. Write a pl/sql program to find a number is ODD OR EVEN
DECLARE
num NUMBER;
BEGIN
num := #
IF num MOD 2=0 THEN
DBMS_OUTPUT.PUT_LINE(num ||' is even');
ELSE
DBMS_OUTPUT.PUT_LINE(num ||' is odd');
END IF;
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;