Thursday, 14 March 2019

Oracle / PLSQL: FOR LOOP

set serveroutput on;
declare
a1 varchar2(100);
begin
select count(*) into a1 from employees;
for i in 1..a1 loop
dbms_output.put_line('Current value is:'|| i);
end loop;
end;
/

Java program to check armstrong number

Program:


package JavaCoders;
class armstrong
{
public static void main(String[] args) 
{
int c=0,a,temp;
int n=153;       //It is the number to check armstrong
temp=n;
while(n>0)
{
a=n%10;
n=n/10;
c=c+(a*a*a);
}
if(temp==c) 
{
System.out.println("armstrong number");
}
else
{
System.out.println("Not armstrong number");
}
}
}

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...