Senin, 18 Januari 2010

Source Code Record Array di Pascal

program record_of_array;
uses crt;
type TArray = array[1..10] of byte;
TMhs = record
nama : string[25];
nim : string[10];
Tugas: TArray;
end;
var mhs:array[1..100] of tMhs;
i,j:byte;
grantRata,R,ratasum:real;
jum,sum:integer;
begin
clrscr;
for i:=1 to 100 do
begin
write('Input nama mahasiswa ke-',i,':');
readln(mhs[i].nama);
write('input NIM mahasiswa ke-',i,':');
readln(mhs[i].nim);
for j:=1 to 7 do
begin
write('input Tugas mahasiswa ',i,' yg ke-',j,':');
readln(mhs[i].tugas[j]);
end;
writeln;
end;
GrantRata:=0;
for i:=1 to 100 do
begin
jum:=0;
for j:=1 to 7 do
begin
jum:=jum + mhs[i].tugas[j];
end;
R:=jum/7;
grantRata:=grantRata+R;
end;
sum:=0;
for i:=1 to 100 do
begin
sum:=sum+mhs[i].tugas[5];
end;
Ratasum :=sum/100;
writeln;
writeln('Rata-rata Nilai semua Mahasiswa:',grantrata/100:3:2);
writeln('Rata-Rata NIlai tugas ke-5 :',ratasum:3:2);
readln;
end.

0 comments:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Enter your email address to subscribe:

Delivered by FeedBurner

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | SharePoint Demo