FORTRAN
integer f,faktorial
write(*,'(A,\)')'Berapa Faktorial?'
read(*,'(i2)');
f=faktorial(j)
write(*,'(A,\)')'1'
do k=2,j
write(*,'(A,i2,\)')'x',k
end do
write(*,'(A,i10)'=',f
end.
integer function faktorial(n)
faktorial=1
do 500 i=2,n
500 faktorial= faktorial*i;
end
output
Berapa Faktorial = 5
1x2x3x4x5 = 120
PL/SQL
set serveroutput on
DECLARE
J INTEGER;
BEGIN
J:= 0;
LOOP
J:=J+1;
DBMS_OUTPUT.PUT_LINE('DENIS BELAJAR PL/SQL');
EXIT WHEN J= 10;
END LOOP;
END;
/
output
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL
DENIS BELAJAR PL/SQL'
pl/sql procedure succesfully completed
set serveroutput on
DECLARE
A INTEGER
JUMLAH INTEGER:= 0;
BEGIN
A:= 2;
LOOP
JUMLAH:=JUMLAH+A;
A:=A+2;
EXIT WHEN A >10;
END LOOP;
DBMS_OUTPUT.PUT_LINE('JUMLAH='||JUMLAH);
END;
/
output
JUMLAH= 30
pl/sql procedure succesfully completed
Logika
A | JUMLAH
2 | 0
4 | 2
6 | 6
8 | 12
10 | 20
12 | 30
set serveroutput on
B INTEGER
BEGIN
B:= 1;
WHILE(B<=10)LOOP
DBMS_OUTPUT.PUT_LINE('DENIS SOPYAN');
B:=B+1;
END LOOP;
END;
/
output
DENIS SOPYAN
DENIS SOPYAN
DENIS SOPYAN
DENIS SOPYAN
DENIS SOPYAN
DENIS SOPYAN
DENIS SOPYAN
DENIS SOPYAN
DENIS SOPYAN
DENIS SOPYAN
pl/sql procedure succesfully completed
set serveroutput on
DECLARE
BIL INTEGER:= 2;
HASIL INTEGER:= 1;
D INTEGER;
BEGIN
D:= 0;
WHILE D <6 LOOP
HASIL:=HASIL*BIL;
D:=D+1;
END LOOP;
DBMS_OUTPUT.PUT_LINE('HASIL DARI 2^6='||HASIL);
END;
/
output
HASIL DARI 2^6= 64
D | HASIL
0 | 1
1 | 2
2 | 4
3 | 8
4 | 16
5 | 32
6 | 64
Minggu, 29 Maret 2009
LAPORAN AKHIR 2 ^SEMESTER 8^
Diposting oleh denis di 05.58
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar