Contoh program pascal data mahasiswa dengan menggunakan array dan record
uses crt;
type mhs = record
nama:string[15];
nim:string[9];
nilai:integer;
end;
var dtmhs:array [1..100] of mhs;
i,n:integer;
grade:char;
procedure input;
begin
clrscr;
write('Masukkan Jumlah Data : '); readln(n);
clrscr;
for i:=1 to n do
with dtmhs[i] do
begin
writeln('Data ke-',i);
write('Nama : '); readln(nama);
write('NIM : '); readln(nim);
write('Nilai : '); readln(nilai);
writeln;
end;
readkey;
end;
procedure output;
begin
clrscr;
writeln(' __________________________________________________');
writeln('| NO | NIM | NAMA | NILAI | GRADE |');
writeln('|--------------------------------------------------|');
writeln('| | | | | |');
for i:=1 to n do
with dtmhs[i] do
begin
writeln('| | | | | |');
gotoxy(3,i+3); writeln(i);
gotoxy(8,i+3); writeln(nim);
gotoxy(20,i+3); writeln(nama);
gotoxy(38,i+3); writeln(nilai);
if nilai<50 then grade:='E';
if nilai>=50 then grade:='D';
if nilai>=60 then grade:='C';
if nilai>=70 then grade:='B';
if nilai>=80 then grade:='A';
gotoxy(46,i+3); writeln(grade);
end;
writeln('|__________________________________________________|');
readkey;
end;
{Program Utama}
begin
input;
output;
end.
Berikut output programnya :
1. Menginput jumlah data
2. Mengisi data
3. Tabel hasil data yang di input
3 komentar
Bang kok saya pas jalankan program nya hasilnya malah AAAAA semua?
Bang bisa tolong jelasin program di atas gk???
Terimakasih banyak ya bang Faisal...sangat bermanfaat untuk saya...semoga murah rezeki ya ...aamiin
EmoticonEmoticon