Skip to main content

Pl/sql imp program

Full course of c++ programming language

Click here > C++ programming language



1 ] print the message in pl/sql block. 

set serveroutput on;

begin

 dbms_output.put_line('Welcome to pl/sql world');

end;

/


==========================================

2 ] create a pl/sql block for print 1 to 10 numbers. 


set serveroutput on;

declare

 i number:=1;

begin

 while(i<=10)

  loop

   dbms_output.put_line(i);

   i:=i+1;

  end loop;

end;

/

==========================================

3 ] create a pl/sql block for print any message for number of time? 


set serveroutput on;

declare

 i number:=1;

begin

 while(i<=5)loop

  dbms_output.put_line('Hello world');

  i:=i+1;

 end loop;

end;

/


==========================================

4 ] create a pl/sql block for print the message for particular times? 

set serveroutput on;

declare

 msg varchar(25):=&message;

 n number:=&n;

 i number:=1;

begin

 while i<=n loop

  dbms_output.put_line(msg);

  i:=i+1;

 end loop;

end;

/


==========================================

6] create a pl/sql block for find the area of circle? 


set serveroutput on;

declare

 r number:=&radious;

 pi number:=3.14;

 ans number;

begin

 ans:=pi*r*r;

 dbms_output.put_line('The area of circle is '||ans);

end;

/


==========================================

7 ] create a pl /sql block for find the simple interest? 

set serveroutput on;

declare

 p number:=&p;

 r number:=&r;

 n number:=&n;

 si number;

begin 

 si:=(p*r*n)/100;

 dbms_output.put_line('The simple interest is '||si);

end;

/


==========================================

8 ]create a pl/sql block for check the number is positive, negative and zero? 

set serveroutput on;

declare

 n number:=&n;


begin 

 if(n>0) THEN

  dbms_output.put_line('Positive number');

 elsif(n=0) THEN

  dbms_output.put_line('Zero number');

 else

  dbms_output.put_line('Negative number');


 end if;

end;

/


==========================================

9 ] create a pl/sql block for print the fibbonacci series? 

set serveroutput on;

declare

 n number:=&n;

 a number:=0;

 b number:=1;

 c number;

 i number:=1;

begin

 while i<=5 loop

  dbms_output.put_line(a);

  c:=a+b;

  a:=b;

  b:=c;

  i:=i+1;

 end loop;

end;

/


==========================================

10 ] create a pl/sql block for print the multiplication table? 


set serveroutput on;

declare

 n number:=&n;

 i number:=1;

 ans number;

begin

 while(i<=10)loop

  ans:=n*i;

  dbms_output.put_line(n||'x'||i||'='||ans);

  i:=i+1;

 end loop;

end;

/


==========================================

11 ] Create a pl/sql block for check the number is prime or not? 


set serveroutput on;


declare

 n number:=&n;

 r number;

 s number;

 i number:=1;

 c number:=1;

begin

 s:=n;

 while(i!=n)loop

  if mod(n,i)=0 then

   c:=c+1;

  end if;

 i:=i+1;

 end loop;

 if c=2 then

  dbms_output.put_line('This number is prime');

 else

  dbms_output.put_line('This number is not a prime');

 end if;


end;

/



==========================================

12 ]Create a pl/sql block for find the number is armstrong Or not? 


set serveroutput on;

declare

 n number:=&n;

 temp number:=n;

 arm number:=0;

 r number;

begin

 while temp>0 loop

  r:=mod(temp,10);

  arm:=arm+(r*r*r);

  temp:=floor(temp/10); 

 end loop;

 dbms_output.put_line(arm);

 dbms_output.put_line(n);

 if n=arm then

  dbms_output.put_line('This number is armstrong');

 else

  dbms_output.put_line('This number is not a armstrong');

 end if;


end;

/


==========================================

13]Create a pl/sql block for find the factorial of number? 


set serveroutput on;


declare

 n number:=&n;

 i number:=n;

 fac number:=1; 

begin

 while(i>0)loop

  fac:=fac*i;

  i:=i-1;

 end loop;

 dbms_output.put_line('The factorial of '||n||'number is'||fac);


end;

/







Comments

Popular posts from this blog

C++ programming language

                c++ is a general programming language and is widely used nowadays for competitive programming. It has imperative, object-oriented and generic programming features.C++ runs on lots of platforms like Windows, Linux, Unix, Mac etc.   ❖❖  C++ with oops ❖❖

7. Switch Statement in c++

 ❖ C++ switch Statement :-                Consider a situation in which, only one block of code needs to be executed among many blocks. This type of situation can be handled using nested if...else statement but, the better way of handling this type of problem is using switch...case statement.  Syntax of switch:-      Switch(expression) {            Case value1 : statement1;                       Break;             Case value2 : statement2;                      Break;             Default : default statements;  }               The expression is either an integer or a character in above syntax. If the expression matches constant in case, the relevant codes a...

3. Input /output in c++

  ➢   Input/ Output in C++ :-        C++ comes with libraries which provides us many ways for performing input and output. In C++.        input and output is performed in the form of sequence of bytes or more commonly known as  streams. ● Input Stream: If the direction of flow of bytes is from device(for example: Keyboard) to the main memory then this process is called input. ● Output Stream: If the direction of flow of bytes is opposite, i.e. from main memory to device(display screen ) then this process is called output. ● Header files available in C++ for Input – Output operation are: • iostream: iostream stands for standard input output stream. This header file contains definitions to objects like cin, cout, cerr etc. • fstream: This header file mainly describes the file stream. This header file is used to handle the data being read from a file as input or data being written into the file as output.       ...