Tuesday, May 3, 2011

Program Menghitung Rata-Rata

Program Menghitung_Rata_Rata;
Uses Wincrt;
Var n,x,i,tot:integer;
    rata:real;
Begin
  Writeln('Program Menghitung Rata-Rata');
  Writeln('============================');
  Writeln;
  Write('Masukkan Jumlah Bilangan: ');readln(n);
  Writeln;
  Writeln('Masukkan Bilangan: ');
  tot:=0;
  For i:= 1 to n do
    Begin
      Readln(x);
      tot:=tot+x;
    End;
  rata:=tot/n;
  Writeln;
  Writeln('Total Bilangan: ',tot:6);
  Writeln('Rata-Rata     : ',rata:6:2);
End.
Outputnya:

0 comments:

Post a Comment