Program Pascal - Deret Bilangan Segitiga dan Fibonacci (NON REKURSIF)
Source Code:
program Der_bil_sgtg_fibo_NON_REK;
uses crt;
var pil:char;
procedure menu1;
var n,i: integer;
j:real;
begin
clrscr;
writeln;
writeln('>> Deret Bilangan Segitiga <<');
writeln;
write(' Input Bilangan : '); readln(n);
writeln;
write(' Hasil : ');
for i:= 1 to n do
begin
j:= 0.5*(i*(i+1));
write(' ',j:2:0);
end;
readkey;
end;
procedure menu2;
var n,i,j,k,l : integer;
begin
clrscr;
writeln;
writeln('>> Deret Bilangan Fibonacci <<');
writeln;
write (' Masukkan Banyak Deret = ');readln(n);
writeln;
write (' Hasil : ');
k:=1;
l:=0;
for i:=1 to n do
begin
write(' ',k);
j:=k+l;
l:=k;
k:=j;
end;
readkey;
end;
BEGIN
repeat
clrscr;
writeln;
writeln('>> PROGRAM BIL. SEGITIGA & FIBONACCI NON REKURSIF <<');
writeln;
writeln(' ------>>>>> Menu Utama <<<<<-------- ');
writeln;
writeln(' [1] Bilangan Segitiga');
writeln(' [2] Bilangan Fibonacci');
writeln(' [0] Exit Program');
writeln;
write ('Pilihan : ');pil:=readkey;
case pil of
'1':menu1;
'2':menu2;
end;
until
pil='0';
END.
Posting Komentar