pl/sql program to check weather given number is Prime or not.
Procedure:
declare
num number;
i number:=1;
c number:=0;
begin
num:=#
for i in 1..num
loop
if((mod(num,i))=0)
then
c:=c+1;
end if;
end loop;
if(c>2)
then
dbms_output.put_line(num||' not a prime');
else
dbms_output.put_line(num||' is prime');
end if;
end;
/
Execution:
SQL> @e:\plsql\prime.sql
Enter value for num: 5
old 6: num:=#
new 6: num:=5;
5 is prime
Conclusion:
A pl/sql program is successfully executed to check the given number is prime or not.
Procedure:
declare
num number;
i number:=1;
c number:=0;
begin
num:=#
for i in 1..num
loop
if((mod(num,i))=0)
then
c:=c+1;
end if;
end loop;
if(c>2)
then
dbms_output.put_line(num||' not a prime');
else
dbms_output.put_line(num||' is prime');
end if;
end;
/
Execution:
SQL> @e:\plsql\prime.sql
Enter value for num: 5
old 6: num:=#
new 6: num:=5;
5 is prime
Conclusion:
A pl/sql program is successfully executed to check the given number is prime or not.
can i install a compiler of sql and pl/sql in windows 7.?? if it is only for windows xp then i need to install it, but where to download that compiler for xp..??
ReplyDeleteI want code for find prime number using procedure concept in plsql
ReplyDeleteI want code for find prime number using procedure concept in plsql
ReplyDeleteThis is anonymous block.. please use it as procedure it will work for you :-)
Delete