ex: * menghitung rata-rata dari 3 bilangan input
*algoritma rata-rata*
deklarasi b1 = integer b2 = integer b3 = integer total = integer rata-rata = real
deskripsi
write(masukkan bilangan 1 = )
read(b1)
write(masukkan bilangan 2 = )
read(b2)
write(masukkan bilangan3 = )
read(b3)
total = b1+b2+b3
rata-rata = total/3
write (bilangan 1=,b1)
write (bilangan 2=,b2)
write (bilangan 3=,b3)
write(total=,total)
*program rata-rata*
uses crt;
var
b1,b2,b3,total:integer;
rata-rata:real;
begin
write('masukkan bilangan 1=');
readln(b1);
write('masukkan bilangan 2=');
readln(b2);
write('masukkan bilangan 3=');
readln(b3);
total:=b1+b2+b3;
rata-rata:=total/3
writeln('bilangan 1=',b1);
writeln('bilangan 2=',b2);
writeln('bilangan 3=',b3);
writeln('total=',total);
writeln('rata-rata=',rata-rata);
readln;
end.
1 komentar:
yoi...yoi....
Posting Komentar