Pages - Menu

Senin, 19 Desember 2011

Program Temuan...^_^


heheheh, dari judulnya pasti bikin ketawa...
program ini nih,aku temuin di email statistika 2011....,
dan aku coba,,,,
eh, ternyata......





Bisaaaaaaa.....^_^



program Temuan;
uses wincrt;

var
nomor : integer;
v,e,s,c : real;
n, d, no : integer;
i,j,k,l : integer;
jawab: string[5];

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 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;

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;
                         
procedure pilihan;
begin
write('nilai x           = ');readln(d);
write('jumlah iterasi    = ');readln(n);
end;


begin
write('Fungsi yang dipilih : ');
writeln;
writeln('1. fungsi eksponensial');
writeln('2. fungsi sin (x)');
writeln('3. fungsi cos (x)');
write ('masukkan pilihan anda (1/2/3)'); read (nomor);
clrscr;

case nomor of
1:begin
pilihan;
writeln;
writeln(eksp(d):5:2);
end;

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

3:begin
pilihan;
writeln;
writeln(cos(d):5:2);
end;
end;
begin
writeln ('ingin menghitung lagi (iya/tidak)'); readln (jawab);
if jawab = 'iya' then
clrscr;
write ('masukkan pilihan anda (1/2/3)'); read (nomor);
end;
end.

4 komentar:

  1. alhamdulillah.. cemungud yah adek.. ^^
    haha.. alay addicted.

    BalasHapus
  2. Alhamdulillah y adik RJ'ers, sesuatu ya..

    BalasHapus
  3. hmmmm, warna-warni mba siapa ya?

    BalasHapus
  4. riska...bisa bkin mobil gerak bolak balik pake pascal gak? -.-

    BalasHapus