Cara
menghitung program rata-rata
v Program Rata_rata;
v uses Crt;
v var i, N : byte;
v Jumlah, Rata : real;
v X : array[1..255] of real;
v Begin
v Clrscr;
v Write(‘banyaknya data (maksimum 255) ?’);
v readln(N);
v Jumlah := 0;
v For
i := 1 to N do
v Begin
v Write(‘Data ke ‘, i, ‘ = ‘);
readln(X[i]);
v Jumlah := Jumlah + X[i];
v End;
v Rata := Jumlah / N;
v writeln(‘banyaknya data = ‘, N);
v writeln(‘Data-data dari X[i]’);
v for i := 1 to N do
v begin
v write(x[i]);
v end;
v writeln(‘Jumlah nilai data = ‘, Jumlah :7:2);
v writeln(‘Rata-rata data = ‘, Rata:6:2);
v end.