You are on page 1of 3

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment-2

Student Name: ADITYA VASHISHT UID: 22BCS16206


Branch: BE-CSE Section/Group: 802-B
Semester: 4th Date of Performance:05.03.2024
Subject Name: DBMS LAB Subject Code: 22CSH-254

1. Aim:
i) Write a PL/SQL code to check if a no is even or odd.
ii) Write a PL/SQL code to print first n no with a difference of 3 and
starting from 1.
DBMS script :
i)

1. connect sys as sysdba;


2. enter password:
3. set serveroutput on;
4. declare
5. a number(10):=&a;
6. b number(10);
7. begin
8. b:=mod(a,2);
9. if (b=0) then
10. dbms_output.put_line('Inputted no is even');
11. else
12. dbms_output.put_line('Inputted no is odd');
13. end if ;
14. end;
15. /
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

ii)

1. connect sys as sysdba;


2. enter password:
3. set serveroutput on;
4. declare
5. n number(10):=&n;
6. i number (10):=1;
7. begin while(n>0) loop
8. dbms_output.put_line(i);
9. n:=n-1;
10. i:=i+3;
11. end loop;
12. end;
13. /

SCREENSHOT OF OUTPUT: PL/SQL code to check if a no is odd or even


DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

PL/SQL code to print first n number with a difference of 3

You might also like