Membuat Program Array Tutorial 3


 Berikut rumus membuat program pascal menggunakan array.
Tutorial Ke 3

Program Array3;
Uses crt;
Var x: array [1..100] of integer;
    n,i,max,min,tot,pos:integer;
    rt,sdt,sd,md:real;
Begin
  Writeln('Program Array');
  Writeln('=============');
  Writeln;
  Write('Masukkan Jumlah Data (Data harus Urut): ');readln(n);
  Writeln;
  For i:= 1 to n do
    Readln(x[i]);
  Writeln;
  Write('Data Yang Telah Dimasukkan: ');
  max:=x[1];
  min:=x[1];
  tot:=0;
  sdt:=0;
  For i:= 1 to n do
    Begin
      Write(x[i],'   ');
      if (max<x[i]) then
        max:=x[i]
      else
        min:=x[i];
      tot:=tot+x[i];
    End;
  rt:=tot/n;
  For i:= 1 to n do
    Begin
      sdt:=sdt+sqr(x[i]-rt);
    End;
  sd:=sqrt(sdt/(n-1));
  if (n mod 2 = 1) then
    begin
      pos:=(n div 2)+1;
      md:=x[pos];
    end
  else
    begin
      pos:=(n div 2);
      md:=(x[pos]+x[pos+1])/2;
readln;
    end; 
  Writeln;
  Writeln('Nilai Maximal   : ',max);
  Writeln('Nilai Minimal   : ',min);
  Writeln('Nilai Rata-Rata : ',rt:4:2);
  Writeln('Standar Deviasi : ',sd:4:2);
  Writeln('Median          : ',md:4:2);
  readln;
End.


Semoga bermanfaat, jangan lupa comment nya ya sobat blogger..??
Terima kasih
Previous
Next Post »