Program Fungsi_dan_prosedur;
uses wincrt;
var Rp:Real;
r : array[1..5] of real;
pilih : char;
n : integer;
hasil : real;
Function R_Paralel : real;
var
i : integer;
hasil : real;
begin
hasil :=0;
for i := 1 to n do
hasil :=hasil+1/r[i];
R_paralel :=1/hasil;
end;
procedure r_seri;
var
i : integer;
begin
hasil:=0;
for i := 1 to n do
hasil:=hasil +r[i];
end;
begin
clrscr;
n:=4;
r[1] :=100;
r[2]:=100;
r[3] :=100;
r[4]:=100;
writeln('pilih S : Rangkaian seri');
writeln('pilih P : Rangkaian paralel');
write('pilihan anda:'); readln(pilih);
case pilih of
'S','s' : begin
R_Seri;
Rp:=Hasil;
end;
'P','p' : begin
Rp:= R_Paralel;
end;
end;
writeln(Rp:10:3); readln;
end.
0 Komentar:
Posting Komentar