ROOTS OF A GIVEN PROGRAM DECLARE a number(4,2); b number(4,2); c number(4,2); d number(7,2); x1 number(7,2); x2 number(7,2); begin a:=10; b:=20; b:=30; d:=power(b,2)-(4*a*c) if(d<0) then dbms_output.put_line('***compiler roots'); else x1:=(-b)+(sqrt(d))/(2*a); x2:=(-b)-(sqrt(d))/(2*a); dbms_output.put_line('First root is:' x1); dbms_output.put_line('Second rootis:' x2); end if; exception when zero then dbms_output.put_line('Value of a should be greater than zero'); end; 2.PALINDROME OR NOT DECLARE name1 varchar(20); name2 varchar(20); l number(5); begin name1:='&name1'; l:=length(name1); while(l>0) loop name2:=name substr(name1,l,1); l:=l-1; end loop; dbms_output.put_line('Reverse of Strip is:' name2); if(name1=name2) then dbms_output.put_line(name1 'is palindrome'); else dbms_output.put_line(name2 'is not palindrome'); end if; end; 3.GIVEN NUMBER IS EVEN OR ODD declare num number(5,2); rem number(5); begin num:='&num'; rem:=mod(num,2); if rem=0 then

dbms_output.put_line('number' num 'is even'); else dbms_output.put_line('number ' num 'is odd'); end if; end;

4.SUM OF NUMBERS declare num number; rem number; sum number; begin num:=123; while(num>0) loop rem:=mod(num,10); sum:=sum+rem; num:=(num/10); end loop; dbms_output.put_line('sum of digits of' num ' is ' sum '); end; 5.FIBONACCI declare num number(5); f1 number(5):=0; f2 number(5):=1; f3 number(5); i number(5):=3; begin num:=10; dbms_output.put_line('the Fibonacci series is'); dbms_output.put_line(f1); dbms_output.put_line(f2); while(i<=num) loop f3:=f1+f2; dbms_output.put_line(f3); f1:=f2; f2:=f3; i:=i+1; end loop; end; 6.SUM AND AVG OF MARKS create or replace procedure sum_marks(m1 number,m2 number,m2 number)is s number s:=m1+m2+m3; dbms_output.put_line('the sum of given marks is:' s); end sum marks; // create or replace procedure avg_marks(m1 number,m2 number,m3 number)is

s number; a number; begin s:=m1+m2+m3; a:=s/3 dbms_output.put_line('the average of given marks is:' a); end avg_marks; sql>/ or declare m1 number(3); m2 number(3); m3 number(3); begin m1=&m1; m2=&m2; m3=&m3; sum_marks(m1,m2,m3); avg_marks(m1,m2,m3); end;

Sign up to vote on this title
UsefulNot useful