1.Write a program to print the following format WELCOME TO PL/SQL PROGRAMMING 2.

Write a program to print the numbers from 1 to 100 declare n number:=1; begin while n<=100 loop dbms_output.put_line(n); n:=n+1; end loop; end; 3.write a program to print the even numbers from 1 to 100 declare n number:=0; begin while n<=100 loop dbms_output.put_line(n); n:=n+2; end loop; end; 4.Write a program to print the odd numbers from 1 to 100 declare n number:=1; begin while n<=100 loop dbms_output.put_line(n); n:=n+2; end loop; end; 5.write a program for multiplication table declare f number(20):=&a; s number(20):=1; l number(20); begin while s<=20 loop l:=f*s; dbms_output.put_line(l||'='||f||'*'||s); s:=s+1; end loop; end; 6.write a program to find the sum of numbers from 1 to 100 declare n number(30):=1; n1 number(30):=0; begin while n<=100 loop n1:=n1+n; n:=n+1; end loop; dbms_output.put_line(n1); end; 7.Write a program to find the sum of all even numbers from 1 to 100 declare n number:=0;

begin while n!=0 loop j:=mod(n.put_line(o).put_line(n1). n1 number:=1.put_line(m). end.Write a program to accept a number and print it in reverse order declare n number(10):=143. o number:=0. m:=(m*10)+j. j number(10):=0. m number:=0.n1 number:=2. n:=trunc(n/10). 10. 8. n:=n+2. begin while n!=0 loop m:=mod(n. begin while n<=100 loop n1:=n1+n.put_line(m). dbms_output. dbms_output. 9.10). n:=trunc(n/10).10). 12. end. end. end loop. end. n:=n+1.put_line(n1). dbms_output.Write a program to accept a number and find how many digits it contain declare n number(30):=14578455. end loop. m number(10). dbms_output. end. begin while n<=100 loop n1:=n1+n. begin m:=length(n).Write a program to accept a number and find the sum of the digits declare n number:=1544. dbms_output. 11. end loop. m number(10):=0. end loop. o:=o+m.Write a program to accept a no and check whether it is Armstrong number or no t declare .Write a program to find the sum of all odd numbers from 1 to 100 declare n number:=1.

end if. z:=trunc(z/10).Write a program to generate all prime numbers between 1 to 100 declare a number:=1.Write a porgram to generate all the Armstrong numbers from 1 to 1000 declare x number. b number:=1. while z>0 loop y:=y+power(mod (z. if cnt=2 then dbms_output.10). begin for i in 1. b:=b+1. c number.'||i).put_line('The given number ' || x || ' is not an armstrong number').put_line('Armstrong Number Is'||' .x number(3). end if. else dbms_output.1000 loop x:=i. end if. y:=0. cnt number:=0. z number(3). . end if. x:=trunc(x/10). end. begin x:=153. 13. if(y=x) then dbms_output. if c=0 then cnt:=cnt+1. if (y = i) then dbms_output. 14. end loop. begin while a<=100 loop b:=1.put_line('prime number').10). while b<=a loop c:=mod(a. end. end loop.put_line('The given number ' || x || ' is an armstrong number').3).b). end loop.put_line('not a prime number').3). loop y:=y + power(mod(x.. y number. exit when x<=0. cnt:=0. z:=x. else dbms_output. y number(3):=0. end loop.

end if. DBMS_OUTPUT. Y := Z. end.N LOOP Z := X + Y. if c=0 then cnt:=cnt+1.PUT_LINE(Z). X := Y.Write a program to aceept a number and check whether it is prime number or no t declare a number:=5. Y number := 1. while x!=0 loop z:=to_char(mod(x. else dbms_output.put_line(z).Write a program to aceept a number and display it in the Octal format declare x number:=&n. end. 17. Z number.put_line('not a prime number').PUT_LINE(Y).Write a program to aceept a number and print it in binary format declare x number:=&n.2))||z. end loop.PUT_LINE(X).put_line('binary format').Write a program to display the fibonacci series from 1 to 10 declare N number := &N. 20. end LOOP. 15. end loop. z varchar2(100).put_line('prime number'). X number := 0. for i in 3. end loop. x:=trunc(x/2). if cnt=2 then dbms_output.a:=a+1. DBMS_OUTPUT. b number:=0. b:=b+1. begin dbms_output. end. dbms_output.b). 16. cnt number:=0. begin DBMS_OUTPUT. y number:=1. end.. end if. y number:=1. begin while b<=a loop c:=mod(a. c number. .

put_line('binary format'). begin while y<=x loop z:=z*y. end . end loop. end loop. dbms_output. y number:=1. end loop. end loop. begin while f!=0 loop s:=1. z number:=1. dbms_output. end. x:=trunc(x/8). end loop. begin while y<=x loop z:=z*y. s:=s+1. l:=0.Write a program to accept a number and print the multiplication tables upto 1 0 declare f number(20):=&n.put_line(f||'*'||s||'='||l). while x!=0 loop z:=to_char(mod(x. l number:=0.put_line(z).z varchar2(100). end. s number(20):=1.8))||z. while s<=20 loop l:=f*s.Find the factorials of numbers from 1 to 10 declare x number:=10. 19. 21.8) declare fah number:=0. y:=y+1. 18. 22. y:=y+1. end . dbms_output.put_line(z). .Write a program to accept a number and find the factorial of the number declare x number:=5. y number:=1.put_line(z). dbms_output. z number:=1. f:=f-1. begin dbms_output.Write a program to accept the temp in Centigrade and convert it into Fahrenhe it(c=F-32/1.

Write a program accept the value of A. end. 27. s number:=0. c number:=&c. area NUMBER. end. dbms_output. begin area:=(22/7)*r. area:=sqrt(sqrt(s*(s-a)*(s-b)*(s-c))). end if.put_line('scalene triangle'). 23. end if. dbms_output.Write a program to accept the 3 sides of the triangle and display the type of triangle declare a NUMBER:=&a. 24. b number:=4. begin s:=(a+b+c)/2. 25. end if.put_line('equilateral trialgle'). area NUMBER:=0.put_line(area). if (a=b or b=c) THEN dbms_output.put_line(perimeter). begin if (a>b AND a>c) . end. 26. dbms_output.put_line(fah).put_line('isosceles trialgle').Write a program to calculate the perimeter of a circle(perimeter=2*PI*r) declare r number:=5.8*cen)+32. begin fah:=(1.Write a program to calculate the area of a triangle by accepting the 3 sides (s=(a+b+c)/2 area=sqrt(s*(s-a)*(s-b)*(s-c))) declare a number:=4. end. c number:=&c.put_line(area). perimeter NUMBER:=0. b number:=&b. end. dbms_output. if (a!=b and b!=c) then dbms_output. begin perimeter:=(44/7)*r.B&C display which is greater declare a NUMBER:=&a.cen number:=&n. b number:=&b. c number:=6.Write a program to calculate the area of a circle by accepting the radius and unit of measure Area=PI*r2 declare r number:=5. begin if (a=b AND b=c) then dbms_output.

rate. b number:=&b. p number:=&p. 33.b. 31.time and find the compoun d interest ci=p*(1+r/100)n declare ci number.put_line(si).put_line('b is big'). temp:=a. a:=b. end.Write a program to accept principle amount . . begin si:=(p*r*t)/100. 28.put_line('a='||a||'b='||b). B and swap the numbers and print the values without using third variable declare a number:=&a. end if. BEGIN dbms_output. end. if (c>a and c>b) then dbms_output. b number:=&b. a:= a.rate. a NUMBER:=&a. b:=temp. dbms_output. temp NUMBER:=0.put_line('before swaping a='||a||'b='||b).B and swap the nos and print the value s. t number:=&t. end. 32. dbms_output. end if.Write a program to accept the side of a square and calculate the area area =a 2 declare s number:=&side.put_line(area). begin area:=power(s.put_line('After swaping a='||a||'b='||b).time calculate the simple in terest si=(p*t*r)/100 declare si number. p number:=&p. a:=a+ b. end if.2). b:=a.put_line('c is big').b.then dbms_output. dbms_output. begin dbms_output. 30.Write a program to accept the values of A .put_line('a='||a||'b='||b).write a program to aceept the principle amount. end.put_line('a is big'). area number.Write a program accept a string and check whether it is palindrome or not 29. if (b>a and b>c) THEN dbms_output. end. dbms_output. r number:=&r.Write a program aceepts the value of A.

s number(6. s number:=0. s:=s+a.. s:=s+f.. s:=s+(1/f).+1/n .put_line(s). end loop. end loop.+n! of 1+1/2+1/3+.. end.i loop f:=f*j. begin for i in 1. s number(6.put_line(s).. dbms_output.2):=0.n loop a:=1/i. end loop.. f:=1.2):=0. s number(6. f number :=1.n loop for j in 1. begin for i in 1.. dbms_output. n number:=&n... f number:=1. dbms_output..i loop f:=f*j.. of 1/1!+1/2!+.WAP to calculate the sum declare n number :=&n.. 34.. end... 37. 35.2):=0..put_line(ci).put_line(s). a number. end. 36.WAP to calculate the sum declare n number:=&n. begin for i in 1.+1/n! of 1/1!+2/2!+.WAP to calculate the sum declare n number:=&n.n loop for j in 1. end. end loop. begin ci:=p*(1+r/100)*n. f number:=1.n loop of 1!+2!+. end loop.r number:=&r... dbms_output.+n/n! ..WAP to calculate the sum declare n number:=&n.... begin for i in 1.....

while d <= wd loop dbms_output. else dbms_output. 38.400)=0 then dbms_output. d:=d+1. 40.1).. begin if mod(y. begin wd:=d+6. wd date.4)=0 and mod(y.put_line(y ||' IS NOT A LEAP YEAR').'DAY')). 42. end.WAP to accept the date and print the weekdays from the given date along with date format declare d date:='&d'. d1 date:='&D1'. end loop. wd date. d:=d+1.i loop f:=f*j. begin wd:=d+6. while d <= wd loop dbms_output. end loop.put_line(to_char(d. dbms_output.'day')||d). end if. 39. end. end loop. end loop. d:=add_months(d.Write a program to accept the date and print the weekdays from the given date declare d date:='&D'.put_line(s).put_line(to_char(d. end.Write a program to accept a year and display all sundays along with the date declare .Write a program to accept a year and check whether it is leap year or not declare y number:=&y.put_line(to_char(d. end. 41.100)!=0 or mod(y.'MONTH')).put_line(y ||' IS A LEAP YEAR').Write a program to display the months between two dates of a year declare d date:='&D'. r number. end. begin while d < d1 loop dbms_output. end loop. s:=s+(i/f).for j in 1.

'O'.length(v) loop c:=substr(v.'D')=1 then dbms_output. if mod(y.'YYYY').put_line('vowel'). dbms_output.'DAY'))||a).Write a program to accept a char and check it is vowel or consonant declare x char:='&x'. if c in ('A'. if v=1 then cnt:=cnt+1.2.366 loop v:=to_char(d.'I'. end. declare d date:='&YEAR'. v varchar2(20).i. end. end loop. .Write a program to accept a year and check whether it is leap year or not.1).100)!=0 or mod(y.'DD-MON-YYYY').y number(4):=&yyyy.400)=0 then for i in 1. 45.. y varchar2(20). i:=i+1.put_line('consonant'). c char. b:=last_day(add_months(a. d:=to_date('01-JAN-'||y). d:=d+1. If it is leap year then display how many sundays present in that year. end if.11)). cnt number(5):=0. else dbms_output. while a <= b loop if to_char(a. cnt number(5):=0. end loop.'D'). end loop. dbms_output. i number(2):=1.WAP to accept a string and count how many vowels present in the string declare v varchar2(300):='&V'.'0')||'-'||upper(to_char(a. end.'E'. 44. begin a:=to_date('01-JAN-'||y. begin for i in 1. a date. end if. 43. end if.put_line(lpad(i.put_line(cnt). begin y:=to_char(d. begin if x='a' or x='e' or x='i' or x='o' or x='u' then dbms_output..'U') then cnt:=cnt+1. a:=a+1.4)=0 and mod(y. b date.put_line(cnt).

begin totmark:=x+y+z.25 per unit iii)>200 units Rs.50)+((tot-100)*.put_line('third'). 47. elsif ave<50 and ave>=35 then dbms_output. else dbms_output.75)+(tot-200)*1.2):=0. p number:=&p.put_line('second'). ave number(5. z number(2):=&m3. else dbms_output.end if. cmr number(5):=&cmr. elsif tot > 100 and tot <= 200 then bill:=(100*. begin if (m*m*m)+(n*n*n)=(o*o*o)+(p*p*p) then dbms_output. tot number(5):=0. y number(2):=&m2. end. dbms_output. end.50)+(100*. end if.50 per unit ii)101-200n units Rs.put_line('first').50.2):=0.WAP or accept marks of 3 subject as i/p and calculate the total marks and div ision of a student i) If totmark>=60 then division is First ii) If totmark <60 and totmark>=50 then division is second iii) If totmark< 50 and >=35 then division is third iv) If totmark< 35 then fail declare x number(2):=&m1.B. end if.put_line('not ramanujan number'). totmark number(5. bill number(7.o.put_line(bill).WAP to accept the CMR & LMR & find out the total bill amount i)0-100 units Rs.25.put_line('fail').put_line(tot).C & D check whether it is Ramanujan number or not declare m number:=&m. 48. 46.2).75). else bill:=(100*.25 per unit declare lmr number(5):=&lmr. dbms_output. begin tot:=cmr-lmr.WAP to accept A. if tot <= 100 then bill:=tot*. elsif ave<60 and ave>=50 then dbms_output. if ave>=60 then dbms_output. o number:=&o. ave:=totmark/3. . end. n number:=&n.put_line('ramanujan number').1.

2). hra 30% of basic.2). str1:=l||str1. s number(5). ns number(8. begin for i in 1. str1 varchar2(100). l varchar2(20). else s:=a.n loop l:=substr(str. v varchar2(1000).put_line(str1).2):=&s. begin n:=length(str).da.2). b:=substr(a.1). dbms_output. c number(5):=0. da 10% of basic.1. end. begin ta:=s*(20/100). .1). 50.2)..WAP to accept a number and print its multiplication table horizontally declare j number:=&j. end loop.i.1). 52. lic number(6.2). end. n number(5).hra. s:=b+c. begin if a>9 then c:=substr(a. b number(5):=0.Write a program to accept a number and find out the sum of first and last dig its declare a number:=&a.WAP to accept the basic salary and find out the ta. gs number(6. 51. end. end loop. end if.. hra:=s*(30/100). da number(6.2).put_line(v). v:=v||j||'*'||i||'='||k||' '.length(a).put_line(s). for i in 1. dbms_output. lic 5% of basic declare s number(6. k number(3).WAP to accept a string and print it in reverse order declare str varchar2(100):='&sTR'. ta number(6. dbms_output. end. hra number(6.10 loop k:=j*i. 49.end if.lic and gs ta 20% of basic.

put_line('LOSS'). b number:=&b.put_line(gs).WAP to accept the cost price and selling price of an item and find the loss o r profit declare cp number:=&cp.WAP to accept the length and breadth of a rectangle and find out the perimete r declare l number:=&l. else p:=cp-sp. l varchar2(10). lic:=s*(5/100).put_line(s).1). begin if cp < sp then p:=sp-cp. a number..Writ a program to generate the following series 53 53 53 53 53 43 43 43 43 33 33 33 23 23 13 declare v number(30).length(n) loop l:=substr(n. end if. end loop. v:=null.put_line(ns). pro number:=0. end. gs:=ta+hra+da. p number. dbms_output...i. 54. dbms_output. dbms_output. dbms_output.put_line('PROFIT'). end. begin for i in 1. 53. .da:=s*(10/100).WAP to accept a no in binary format and print it in decimal format declare n varchar2(20):=&n. end. 55. end loop.put_line('THE PERIMETER OF RECTANGLE IS '||a). end. dbms_output. sp number:=&sp.i loop v:=v||i. 56. begin for i in reverse 1.put_line(v). dbms_output. dbms_output. ns:=gs-lic.6 loop for j in 1. begin a:=2*(l+b).

end if. end loop. end loop. b number:=&b. declare a number:=&a. 58. dbms_output. end if. n:=trunc(n/10).10). dbms_output. if s=9 then dbms_output. m number. end.put_line('BOTH STRINGS ARE EQUAL')..put_line(i).pro:=pro+l*power(2.b loop r:=r*a. 60. elsif length(str1) < length(str2) then dbms_output..put_line('a raised to power of b is '||r). begin for i in 1. s:=s+m. 57. r number:=1. end. begin if length(str1) > length(str2) then dbms_output. str2 varchar2(100):='&str2'.9999 loop n:=i.put_line(i||' ').WAP to accept a sentence and count the no of chars in that sentence declare str varchar2(100):='&str'.put_line(str1 ||' IS GREATER'). s:=0.length(n)-i). end.WAP to accept two strings and display the large one among those declare str1 varchar2(100):='&str1'. else dbms_output.WAP to accept two nos as input and find one no is raised to another one (with out using any function) set serveroutput on.WAP to display all the nos whose sum of digits is 9 from 1 to 9999 declare n number. end. while n>0 loop m:=mod(n. end. end loop. .put_line(str2 ||' IS GREATER'). begin for i in 1. end loop. begin i:=length(str). i number.put_line('DECIMAL NUMBER'). s number:=0. dbms_output. 59.

WAP while purchasing certain items. n:=s. m:=trunc(mod(d.'DAY')||d.. end loop.put_line(y||' YEARS '||m||' MONTHS '||d||' DAYS'). dbms_output.put_line(v). s number:=0.i. end. dis number:=0. end if.61. up number:=&up. .Write a program to accept a string and count the no of individual chars declare v varchar2(100):='&V'. dbms_output. 62. end. begin while length(n)>1 loop for i in 1. if bill > 1000 then dis:=bill*20/1000.7 loop v:=to_char(d. m number.put_line('AMOUNT IS '||amt). dbms_output. d:=mod(mod(d.WAP to accept the date and print all the weekdays along with the given date declare d date:='&D'. s:=0.WAP to accept a no and find the sum in a single digit declare n number:=&n. 65. discount of each is as follows i) If qty purchased > 1000 discount is 20% ii) If the qty and price per item are input then calculate the expenditure declare qty number(5):=&qty. begin y:=trunc(d/365). begin for i in 1. amt number. end loop. end. d:=d+1. end loop. y number.30). v varchar2(20). end. dbms_output.Enter the no of days and find out the no of years and no of days and months declare d number:=&d. amt:=bill-dis.. begin bill:=qty*up. 63.365)/30).length(n) loop s:=s+substr(n.1).365). v1 varchar2(100).put_line('THE SUM IN SINGLE DIGIT IS '||n). 64. bill number.

lb:=length(v1)...put_line('SPACE'||' EXISTS '||diff||' TIMES'). j number. end loop. diff number. 66. .put_line('TOTAL LENGTH OF THE GIVEN STRING '||v||'='||n). c char. end. else dbms_output.1).Write a program to display all combination of 1.0).. while length(v1)>0 loop c:=substr(v1.1.2. m number.Write a program to accept the time in HH & MIN format and find the total seco nds declare h number:=&hour. begin for i in 1.put_line(i||j||k).3 loop dbms_output.. end. v1:=replace(v1..&3 declare i number. cm number. dbms_output. begin s:=(h*60*60)+(m*60). end loop.cm & ft declare d number:=&d.3 loop for j in 1.3 loop for k in 1. n number(5):=0. begin v1:=v. 67. f number. end. 69. end if.put_line(s). s number(10):=0. n:=n+diff. if ascii(c)=32 then dbms_output. diff:=lb-la. k number. la:=nvl(length(v1). dbms_output. la number.Write a program to find out the series 12+22+32+42+.put_line(c||' EXISTS '||diff||' TIMES'). end loop. m number:=&minute.WAP to accept the distance between two cities in km and convert into mts ..++n2 68. end loop.lb number.c). begin m:=d*1000.

dbms_output.. f:=1. end loop.. dbms_output.i)/f). dbms_output. s number:=0.f:=m*3. end loop.3).+xn/n! declare n number:=&n.28.i loop f:=f*j.put_line('meters are' ||m). . x number:=&x.put_line('centimeters are' ||cm).Write a program to find the series x+x2/2!+x3/3!+. dbms_output.. s:=round(s+(power(x. end... 70.n loop for j in 1.. end.put_line('foots are' ||f). f number:=1.put_line(s). cm:=m*100. begin for i in 1.

Sign up to vote on this title
UsefulNot useful