You are on page 1of 4

Charan B

22BCE1618

1.

declare
a int;
b int;
c int;
begin
a:=&a;
b:=&b;
c:=&c;
if(a>b and b>c) then
dbms_output.put_line(a || ' is greatest');
elsif (b>a and b>c) then
dbms_output.put_line(b || ' is greatest');
else
dbms_output.put_line(c || ' is greatest');
end if;
end;
/

2.

declare
amount int;
begin
amount:=&amount;
if (amount>=0) then
dbms_output.put_line(price/100);
else
dbms_output.put_line('Invalid Inputs');
end if;
end;
/

3.

declare
units int;
price int;
begin
units:=&units;
case
when units<=100 then
price:=units;
when units<=200;
price:=100 + 2*(units-100);
when price<=300 then
price:=300 + 3*(units-200);
else
price:=500 + 5*(units-300)
end case;
dbms_output.put_line(price);
end;
/

4.

declare
amount int;
tax int;
begin
amount:=&amount;
case
when amount <= 300000 then
tax:= 0;
when amount <= 600000 then
tax:= 5;
when amount <= 900000 then
tax:= 10;
when amount <= 1200000 then
tax:= 15;
when amount <= 1500000 then
tax:= 20;
else
tax:=30;
end case;
dbms_output.put_line('The tax amount is ' || amount*tax/100);
end;
/

5.

declare
i int;
sum int;
begin
i:=1;
sum:=0;
loop
exit when i>=100;
if(i%3==0) then
dbms_output.put_line(i || ' is divisible by 3');
sum := sum+i;
end if;
i:=i+1;
end loop;
dbms_ouput.put_line('The sum of these numbers is ' || sum);
end;
/

6.

declare
i int;
copy int;
sumcube int;
sumarm int;
begin
i:=1;
loop
exit when i>=100;
copy:=i;
sumcube:=0;
loop;
exit when copy<=0;
sumcube := sumcube + (copy%10)*(copy%10)*(copy%10);
copy := copy/10;
end loop;
if (sumcube==i) then;
dbms_oupput.put_line(i || ' is an armstrong number');
sumarm := sumarm + i;
end if;
i = i+1;
end loop;
dbms_ouput.put_line('The sum of these numbers is ' || sumarm);
end;
/

7.

declare
int n;
int a;
int b;
begin
n:=&n;
a:=0;
b:=1;
loop
exit when n==0;
dbms_output.put_line(a);
b := a+b;
a := b-a;
end loop;
end;
/

You might also like