berikut listing program menghitung nilai rata-rata.
program array_1dimensi;
uses crt;
var
tugas,mid,final : array[1..10] of integer;
rata : array[1..10] of real;
i,byk : byte;
tambah : char;
label input;
begin
input:
write('Masukan banyaknya data :');readl
for i:=1 to byk do
begin
write('Nilai tugas :');
readln(tugas[i]);
write('Nilai Mid :');
readln(mid[i]);
write('Nilai Final :');
readln(final[i]);
rata[i]:=(tugas[i]+mid[i]+final[i])/3;
end;
clrscr;
for i:=1 to byk do
begin
writeln('-----------------------------------');
writeln('| No. | Nilai | Rata |');
writeln('| |---------------------| |');
writeln('| | Tugas | Mid | Final | |');
writeln('-----------------------------------');
for i:=1 to byk do
begin
write('|',i,'|',tugas[i],'|',mid[i],'|',final[i],'|,rata[i]:2:2,'|');
readln;
end;
writeln('-----------------------------------');
write('Ingin input data nilai lagi [Y/T]?');readln(tambah);
if (tambah='Y') or (tambah='y') then
goto input;
readln;
end;
clrscr;
end.
Output dari listing diatas adalah sebagai berikut :
2 Comment:
Mbak main2 ke blog w http://ardeex.blogspot.com
wokeeeh...
Posting Komentar