program rata;
uses wincrt;
var i,n:integer;
x,y,sum,mean:real;
begin
writeln('Banyaknya data= ');
readln(n);sum:=0; i:=0;
repeat
i:=i+1;
writeln('data ke',i,'=');
readln(y);
sum:=sum+y;
until i=n;
mean:=sum/n;
writeln('rata-rata=',mean);
end.
program faktorial
program faktorial;
uses wincrt;
var
i,n,f:integer;
begin
readln(n);f:=1;i:=0;
repeat
i:=i+1;
f:=f*i;
until i=n;
writeln(n,'faktoial= ',f)
end.
program faktorial;
uses wincrt;
var
i,n,f:longint;
begin
readln(n);f:=1;i:=0;
if (n=0) then
writeln (1)
else
repeat
i:=i+1;
f:=f*i;
until i=n;
writeln(n,'faktoial= ',f)
end.
program binomial
program binomial;
uses wincrt;
var n,i,x,s,j,q: integer;
a,b,c,kombinasi,r,p,hasil,hasil2,z:real;
begin
writeln('masukkan nilai n = '); readln(n);
writeln('masukkan nilai x = '); readln(x);
a:=1; b:=1; c:=1;
for i:=2 to n do
a:=a*i;
for i:=2 to x do
b:=b*i;
for i:=2 to (n-x) do
c:=c*i;
kombinasi:=a/(b*c);
writeln(kombinasi);
writeln('p pangkat x');
writeln('masukkan p='); readln(p);
hasil:=1; for i:=1 to x do
hasil:=p*hasil;
writeln('hasil'); writeln(hasil);
begin
writeln('r pangkat q');
writeln('masukkan r='); readln(r);
writeln('masukkan q='); readln(q);
hasil2:=1; for j:=1 to q do
hasil2:=r*hasil2;
writeln('hasil2',hasil2);
end;
begin
z:=kombinasi*hasil*hasil2;
writeln('binomial',z);
end;
end.
faktorial terbalik
program faktorial;
uses wincrt;
var i,N,jumlah:longint;
begin
jumlah:=1;
write ('inputkan nilai N','='); readln (N);
write ('faktorial dari',N,'adalah:');
for i:=1 to N-1 do
begin
write (i,'x');
jumlah:=i*jumlah;
end;
begin
if N<0 then write ('tidak terdefinisi')
else if (N<=1) then write ('1')
else write (N,'=',jumlah);
end;
end.
program varians
uses wincrt;
var i,n:integer;
x,sgm_x,sgm_x2,varian:real;
begin
write ('Berapa jumlah data? ');
readln (n);
for i:=1 to n do
begin
write ('Data ke-',i,' = ');
readln (x);
sgm_x:=sgm_x+x;
sgm_x2:=sgm_x2+sqr(x);
end;
writeln(sgm_x);
writeln(sgm_x2);
varian:=(sgm_x2-(sqr(sgm_x)/n))/(n-1);
write ('varians data adalah = ',varian);
end.uses wincrt;
var i,n:integer;
x,sgm_x,sgm_x2,varian:real;
begin
write ('Berapa jumlah data? ');
readln (n);
for i:=1 to n do
begin
write ('Data ke-',i,' = ');
readln (x);
sgm_x:=sgm_x+x;
sgm_x2:=sgm_x2+sqr(x);
end;
writeln(sgm_x);
writeln(sgm_x2);
varian:=(sgm_x2-(sqr(sgm_x)/n))/(n-1);
write ('varians data adalah = ',varian);
end.
program standar deviasi
program stardar_deviasi;
uses wincrt;
var i,n:integer;
x,sgm_x,sgm_x2,sd:real;
begin
write ('Berapa jumlah data= ');
readln (n);
for i:=1 to n do
begin
write ('Data ke-',i,' = ');
readln (x);
sgm_x:=sgm_x+x;
sgm_x2:=sgm_x2+sqr(x);
end;
writeln(sgm_x);
writeln(sgm_x2);
sd:=sqrt((sgm_x2-(sqr(sgm_x)/n))/(n-1));
write ('standar deviasi data adalah = ',sd);
end.
program modus
program mo;
uses wincrt;
var i,k,j,modus:integer;
A,frek:array[1..100] of integer;
begin
readln(n);
for i:=1 to k do
readln(A[i]);
writeln;
for i:=1 to k-1 do
begin
for j:=i+1 to n do
if A[i]=A[j] then
frek[i]:=frek[i]+1;
end;
modus:=1;
for i:=1 to n do
begin
write(frek[i],' ');
if frek[modus]<frek[i] then
modus:=i;
end;
write('modus: ',A[modus],' sebanyak ',frek[modus]+1);
end.