Pages - Menu

Kamis, 15 Desember 2011

Program Rata-rata


program rata_rata;
uses wincrt;
var n,i :integer;
    sum, mean, x:real;

begin
writeln ('banyaknya data= '); readln (n);
for i:= 1 to n do
begin
     writeln('data ke',i,'=');
     readln (x);
     sum:= sum+x;
     end;
mean:= sum/n;
     writeln ('rata-rata= ', mean:9:4);
     end.
program rata_rata;
uses wincrt;
var n,i :integer;
    sum, mean, x:real;
begin
writeln ('banyaknya data= '); readln (n);
repeat
i:= i +1;
     writeln('data ke',i,'=');
     readln (x);
     sum:= sum+x;
     until i=n;
     mean:= sum/n;
     writeln ('rata-rata= ', mean:9:4);
     end.


program rata_rata;
uses wincrt;
var n,i :integer;
    sum, mean, x:real;
begin
writeln ('banyaknya data= '); readln (n);
repeat
i:= i +1;
     writeln('data ke',i,'=');
     readln (x);
     sum:= sum+x;
     until i=n;
     mean:= sum/n;
     writeln ('rata-rata= ', mean:9:4);
     end.

Tidak ada komentar:

Posting Komentar