program modus

2

Click here to load reader

Upload: lindarosalina

Post on 15-Apr-2017

43 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Program modus

Program Modusprogram nilaimodus;

uses wincrt;

var n,i,j: integer; ftinggi: real; fx: array[1..100]of integer; modus,x: array[1..100]of real;

begin

write ('Masukan banyak data: '); readln (n); for i:=1 to n do begin write ('Data ke-',i,' : '); readln(x[i]); fx[i]:=1; end; for i:=1 to n-1 do for j:=i+1 to n do if x[i]=x[j] then fx[i]:=fx[i]+1; ftinggi:=1; for i:=1 to n do if fx[i]>ftinggi then ftinggi:=fx[i]; writeln; writeln ('Frekuensi tertinggi adalah: ',ftinggi:0:0); writeln;

j:=0; for i:=1 to n do if fx[i]=ftinggi then begin j:= j+1; modus[j]:=x[i]; end; writeln; if j=n then writeln('Tidak ada Modus') else if ftinggi=n div j then writeln('Tidak ada Modus') else begin write ('Banyak modusnya ',j,' buah, yaitu : ' ); for i:=1 to j do

Page 2: Program modus

writeln (modus[i]:0:0); end; end.