0% found this document useful (0 votes)
6 views4 pages

Mac Laurin

Uploaded by

yarno.prc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Mac Laurin

Uploaded by

yarno.prc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

program Deret_Maclaurin;

uses wincrt;

var

v,e,s,c : real;

n, d, no : integer;

i,j,k,l : integer;

jawab : char;

function f(w:integer):real; begin

v:=1;

for i:=1 to w do

v:=v*i;

f:=v;

end;

function eksp(x : integer):real;

begin

for j:=0 to n do begin

e:=e+exp(j*ln(x))/f(j);

writeln('n=',j,' =>',e:5:2);

eksp:=e;

end;end;

function cos(z : integer):real;

begin

for l:=0 to n do begin


if (l mod 2)=0 then begin

c:=c+(exp((2*l)*ln(z)))/f(2*l); end

else begin

c:=c+(-1)*exp((2*l)*ln(z))/f(2*l); end;

writeln('n=',l,' =>',c:5:2);

cos:=c;

end;end;

function sin(y : integer):real;

begin

for k:=0 to n do begin

if (k mod 2)=0 then begin

s:=s+(exp((2*k+1)*ln(y)))/f(2*k+1); end

else begin

s:=s+(-1)*exp((2*k+1)*ln(y))/f(2*k+1); end;

writeln('n=',k,' =>',s:5:2);

sin:=s;

end; end;

procedure pilihan;

begin

write('nilai x = ');readln(d);

write('jumlah iterasi = ');readln(n);

end;

procedure menu;

begin
write('Fungsi yang dipilih : ');

writeln;

writeln('1. fungsi eksponensial');

writeln('2. fungsi cos (x)');

writeln('3. fungsi sin (x)');

writeln;

write('pilihan : ');read(no);

clrscr;

end;

begin

repeat

menu;

if no=1 then begin

pilihan;

writeln(eksp(d):5:2);

end

else if no=2 then begin

pilihan;

writeln(cos(d):5:2);

end

else if no=3 then begin

pilihan;

writeln(sin(d):5:2);
end

else write('angka tidak ada di pilihan');

writeln;

writeln;

repeat

write('Ingin mengulang lagi (Y/T)? ');readln(jawab);

clrscr;

if not ((upcase(jawab) = 'T') or (upcase(jawab) = 'Y')) then

writeln('Tolong masukkan huruf yang benar');

until ((upcase(jawab) = 'T') or (upcase(jawab) = 'Y'));

until (upcase(jawab) = 'T');

write('============selesai=============');

end.

You might also like