w3resource

PL/SQL Control Statement Exercises: Arrange the number of two variable in such a way that the small number will store in num_small variable and large number will store in num_large variable

PL/SQL Control Statement: Exercise-1 with Solution

Write a PL/SQL program to arrange the number of two variable in such a way that the small number will store in num_small variable and large number will store in num_large variable.

Sample Solution:

PL/SQL Code:

DECLARE
num_small NUMBER := 8;
num_large NUMBER := 5;
num_temp NUMBER;
BEGIN

IF num_small > num_large THEN
num_temp := num_small;
num_small := num_large;
num_large := num_temp;
END IF;

DBMS_OUTPUT.PUT_LINE ('num_small = '||num_small);
DBMS_OUTPUT.PUT_LINE ('num_large = '||num_large);
END;
/

Sample Output:

num_small = 5
num_large = 8

Flowchart:

Flowchart: PL/SQL Control Statement Exercises - Arrange the number of two variable in such a way that the small number will store in num_small variable and large number will store in num_large variable

Improve this sample solution and post your code through Disqus

Previous: PL/SQL Control Statement Exercises Home.
Next: Write a PL/SQL procedure to calculate the incentive on a target achieved and display the message either the record updated or not.

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/plsql-exercises/control-statement/plsql-control-statement-exercise-1.php