Cari Blog Ini

Program Mean-Varians

Selasa, 24 Desember 2013
program mean_var;
uses wincrt;
var
i,n:integer;a,b,c,d:real;x:array[1..100] of integer;
begin
write('masukkan jumlah data: ');readln(n);
a:=0;
for i:=1 to n do
begin
write('x[',i,']= ');readln(x[i]);
a:=a+x[i];
end;
writeln;
writeln('rata-rata: ',a/n:0:2);
for i:=1 to n do         
begin
b:=x[i]-(a/n);
c:=b*b;
d:=d+c;
end;
writeln('varians: ',d/(n-1):0:2);
end.


0 komentar:

Posting Komentar