WAP to print the maximum number using function.
create or replace function findmax(x number, y number)
return number
is
z number;
begin
if x>y then
z:=x;
else
z:=y;
end if;
return z;
end;
set serveroutput on
declare
a number;
b number;
c number;
begin
a:=&a;
b:=&b;
c:=findmax(a,b);
dbms_output.put_line('maximun'||c);
end;
Results
old 6: a:=&a;
new 6: a:=10;
old 7: b:=&b;
new 7: b:=12;
maximun12
PL/SQL procedure successfully completed.
declare
a number;
b number;
c number;
function findmax(x number, y number)
return number
is
z number;
begin
if x>y then
z:=x;
else
z:=y;
end if;
return z;
end;
begin
a:=&a;
b:=&b;
c:=findmax(a,b);
dbms_output.put_line('Maximun'||c);
end;
Results
old 18: a:=&a;
new 18: a:=12;
old 19: b:=&b;
new 19: b:=15;
Maximun15
PL/SQL procedure successfully completed.
create or replace function findmax(x number, y number)
return number
is
z number;
begin
if x>y then
z:=x;
else
z:=y;
end if;
return z;
end;
set serveroutput on
declare
a number;
b number;
c number;
begin
a:=&a;
b:=&b;
c:=findmax(a,b);
dbms_output.put_line('maximun'||c);
end;
Results
old 6: a:=&a;
new 6: a:=10;
old 7: b:=&b;
new 7: b:=12;
maximun12
PL/SQL procedure successfully completed.
OR
set serveroutput ondeclare
a number;
b number;
c number;
function findmax(x number, y number)
return number
is
z number;
begin
if x>y then
z:=x;
else
z:=y;
end if;
return z;
end;
begin
a:=&a;
b:=&b;
c:=findmax(a,b);
dbms_output.put_line('Maximun'||c);
end;
Results
old 18: a:=&a;
new 18: a:=12;
old 19: b:=&b;
new 19: b:=15;
Maximun15
PL/SQL procedure successfully completed.
No comments:
Post a Comment