MEMBUAT PROGRAM ARRAY DALAM RECORD

uses wincrt ;

type tb_mhs=record
nim : longint ;
nama : string ;
nilai: integer;
end;

var
mhs:array [1..10] of tb_mhs;
a,b,ke: integer;
tuker:tb_mhs;
pilih: char;
posisi : array [1..10] of integer;

begin
pilih :='y';
while ((pilih ='y')or (pilih='y'))do
begin
ke := ke + 1;
writeln;
writeln('masukkan data mahasiswa ke ',ke,':');
writeln('===================================');
write('masukan nim : '); readln (mhs[ke].nim);
write('masukan nama : '); readln (mhs[ke].nama);
write('masukan nilai : '); readln (mhs[ke].nilai);
writeln('===================================');
write('ingin tambah mahasiswa ? y/t:') ; readln (pilih);
end;

for a:=1 to ke do
begin
for b:=a+1 to ke do
begin
if mhs [a].nilai tukar:=mhs[a];
mhs[a]:=mhs[b];
mhs[b]:=tuker;
end;

clrscr;
for a:=1 to ke do
begin
writeln;
writeln(' TABEL MAHASISWA ');
writeln('--------------------------------');
writeln('NO | NIm | Nama | nilai | ');
writeln('=============================');

for a:=1 to ke do
writeln(a:4,'|',mhs[a].nim:7,'|',mhs[a].nama:8,'|',mhs[a].nilai:8,'|',);
writeln('----------------------------');
end;
end;
end.


referensi
http://www.facebook.com/pages/School-Distortion/168387393217020
Share:

0 comments:

https://fikiirawan.blogspot.com/

Blog Archive

Pages