declare n number; i number; flag number; begin i:=2; flag:=1; n:=7; for i in 2..n/2 loop if mod(n,i)=0 then flag:=0; exit; end if; end loop; if flag=1 then dbms_output.put_line('prime'); else dbms_output.put_line('not prime'); end if; end; / Output is attached below:
declare
n number;
i number;
flag number;
begin
i:=2;
flag:=1;
n:=7;
for i in 2..n/2
loop
if mod(n,i)=0
then
flag:=0;
exit;
end if;
end loop;
if flag=1
then
dbms_output.put_line(‘prime’);
else
dbms_output.put_line(‘not prime’);
end if;
end;
/
DECLAREi number(3);j number(3);BEGINi := 2;LOOPj:= 2;LOOPexit WHEN ((mod(i, j) = 0) or (j = i));j := j +1;END LOOP;IF (j = i ) THENdbms_output.put_line(i || ' is prime ');END IF;i := i + 1;exit WHEN i = 40;END LOOP;END;/
DECLARE i number(3); j number(3); BEGIN 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_line(i || ' is prime '); END IF; i := i + 1; exit WHEN i = 40; END LOOP; END; /
Q.Write a program in PL/SQL to insert records from one table to another.
DOWNLOAD ATTACHMENT:
DOWNLOAD ATTACHMENT:
See lessWrite a program in PL/SQL to print the value of a variable inside and outside a loop using LOOPEXIT statement.
Download the attachment for answer.
Download the attachment for answer.
See lessWrite a program in PL/SQL to check whether a number is prime or not using goto statement with for loop.
DOWNLOAD ATTACHMENT FOR ANSWER
DOWNLOAD ATTACHMENT FOR ANSWER
See lessWrite a program in PL/SQL to check whether a number is prime or not using goto statement with for loop.
declare n number; i number; flag number; begin i:=2; flag:=1; n:=7; for i in 2..n/2 loop if mod(n,i)=0 then flag:=0; exit; end if; end loop; if flag=1 then dbms_output.put_line('prime'); else dbms_output.put_line('not prime'); end if; end; / Output is attached below:
declare
n number;
i number;
flag number;
begin
i:=2;
flag:=1;
n:=7;
for i in 2..n/2
loop
if mod(n,i)=0
then
flag:=0;
exit;
end if;
end loop;
if flag=1
then
dbms_output.put_line(‘prime’);
else
dbms_output.put_line(‘not prime’);
end if;
end;
/
Output is attached below:
See lessWrite a program in PL/SQL to show the uses of nested loop.
DECLAREi number(3);j number(3);BEGINi := 2;LOOPj:= 2;LOOPexit WHEN ((mod(i, j) = 0) or (j = i));j := j +1;END LOOP;IF (j = i ) THENdbms_output.put_line(i || ' is prime ');END IF;i := i + 1;exit WHEN i = 40;END LOOP;END;/
1. Create a class of SalesPersons as a thread that will display five salespersons names. 2. Create a class as Days as other Thread that has an array of seven days. 3. Call the instance of SalesPersons in Days and start both the threads 4. suspend SalesPersons on Sunday and resume on Wednesday Note: use suspend, resume methods from the thread
C++ Code with Output
C++ Code with Output
See less