Title | Dbms 2.1 20BCS5865 - Write a program in PL/SQL to print the prime numbers between 1 to 100. Write |
---|---|
Author | Stunner Rudra |
Course | Database Systems |
Institution | Chandigarh University |
Pages | 7 |
File Size | 424.9 KB |
File Type | |
Total Downloads | 77 |
Total Views | 161 |
Write a program in PL/SQL to print the prime numbers between 1
to 100.
Write a PL/SQL program to check whether a given number is positive,
negative or zero....
Worksheet - 2.1 NAME- Tanish Gaba UID - 20BCS5865 Class - CSE 28(A) Subject- DBMS Lab
SEMESTER - 3rd
Questions:1 1.Aim/Overview of the practical: Write a program in PL/SQL to print the prime numbers between 1 to 100. 2.Steps for experiment/practical/Code: DECLARE i NUMBER(3); j NUMBER(3); BEGIN dbms_output.Put_line('The prime numbers are:'); dbms_output.new_line; i := 2; LOOP j := 2;
LOOP
EXIT WHEN( ( MOD(i, j) = 0 )
OR ( j = i ) );
j := j + 1;
END LOOP;
IF( j = i )THEN
dbms_output.Put(i||' ');
END IF;
i := i + 1;
exit WHEN i = 100;
END LOOP;
dbms_output.new_line;
END;
/
3.Result/Output/Writing Summary:
Questions:2 1. Aim/Overview of the practical: Write a PL/SQL program to check whether a given number is positive, negative or zero.
2. Steps for experiment/practical/Code: DECLARE n NUMBER := -5; BEGIN IF SIGN (n) < 0 THEN DBMS_OUTPUT.put_line ('Number is negative.'); ELSIF SIGN (n) = 0 THEN DBMS_OUTPUT.put_line ('Number is zero.'); ELSE DBMS_OUTPUT.put_line ('Number is positive.'); END IF; E N D; /
3. Result/Output/Writing Summary: For Positive Number:
For Negative Number:
For Zero Number
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty): Sr. No. Parameters Marks Obtained Maximum Marks 1. 2. 3....