Menghitung nilai Sin dengan sudut radian
Thursday, June 13, 2013
program sin(x);
uses crt;
const pi = 3.14;
var
x,rad,p1,tot : real;
n,i,faktor,p2,j : integer;
tanda : byte;
begin
clrscr;
writeln(‘ Menentukan nilai sin(x)’);
write(‘Nilai x = ‘); readln(x);
write(‘Masukkan pangkat = ‘); readln(n);
rad := pi*x/180;
i := 1;
tanda := 1;
while i <= n do
begin
p1 := exp(i*ln(rad));
faktor := 1;
for j := 1 to i do
faktor := faktor *j;
p2 := faktor;
tot := tot + (tanda*p1/p2);
tanda := (-1)*tanda;
i := i+2;
end;
writeln(‘Sin(‘,x:5:2,’) = ‘,tot:5:2);
readln;
end.