Record
Record merupakan suatu kumpulan data item yang masing-masing mempunyai jenis data berbeda. Data item yang merupakan elemen record biasanya disebut dengan FIELD.
1. Program
uses wincrt;
type
Mahasiswa = Record
Nama :string[30];
NIM :string[10];
Alamat :string[50];
end;
var
Begin
clrscr;
write('Nama : ');readln(Mhs.Nama);
write('NIM : ');readln(Mhs.NIM);
write('Alamat : ');readln(Mhs.Alamat);
writeln;
writeln('Nama Anda : ',Mhs.Nama);
writeln('NIM Anda : ',Mhs.NIM);
writeln('Alamat Anda : ',Mhs.Alamat);
end.
Output
2. Program
uses wincrt;type
hasil=record
sisi:integer;
luas:integer;
keliling:integer;
end;
var
sisi:integer;
luas:integer;
keliling:integer;
bujursangkar:hasil;
begin
write ('Masukkan panjang sisi = '); readln(bujursangkar.sisi);
luas:=bujursangkar.sisi*bujursangkar.sisi;
keliling:=4*bujursangkar.sisi;
writeln;
writeln ('Luasnya = ', luas);
writeln ('Kelilingnya = ', keliling);
end.
Output
3. Program
uses wincrt;
type
mahasiswa=record
n:string[20];
nim:string[20];
jk:string[20];
agama:string[20];
alamat:string[30];
end;
var
data:mahasiswa;
begin
write('Nama = '); readln(data.n);
write('NIM = '); readln(data.nim);
write('Jenis Kelamin = '); readln(data.jk);
write('Agama = '); readln(data.agama);
write('Alamat = '); readln(data.alamat);
writeln;
writeln('Nama = ',data.n);
writeln('NIM = ',data.nim);
writeln('Jenis Kelamin = ',data.jk);
writeln('Agama = ',data.agama);
writeln('Alamat = ',data.alamat);
end.
Output
4. Program
uses wincrt;
type
potensial = record
ep1,m,g,h:integer;
end;
var
ep:potensial;
begin
writeln('----------------------------------------------------------------------');
writeln('MENGHITUNG BESAR ENERGI POTENSIAL');
writeln('----------------------------------------------------------------------');
write('Masukkan nilai massa benda (m) = '); readln(ep.m);
write('Masukkan nilai percepatan gravitasi (g) = '); readln(ep.g);
write('Masukkan nilai tinggi benda (h) = '); readln(ep.h);
writeln;
ep.ep1:=ep.m*ep.g*ep.h;
writeln('Besar energi potensial adalah ',ep.ep1);
writeln('----------------------------------------------------------------------');
end.
Ouput
5. Program
uses wincrt;
type
mahasiswa=record
nama:string;
kelas:string;
nilai:integer;
ket:string;
end;
var
mhs:array [1..62] of mahasiswa;
data,i:integer;
begin
write ('Banyak Data = '); readln (data);
writeln;
for i:=1 to data do
begin
write ('Nama = '); readln (mhs[i].nama);
write ('Kelas = '); readln (mhs[i].kelas);
write ('Nilai = '); readln (mhs[i].nilai);
writeln;
if mhs[i].nilai>65 then
mhs[i].ket:='Lulus'
else
mhs[i].ket:='Tidak Lulus';
end;
writeln ('-------------------------------');
writeln ('No Nama Kelas Nilai Ket');
writeln ('-------------------------------');
for i:= 1 to data do
begin
writeln (i,' ',mhs[i].nama,' ',mhs[i].kelas,' ',mhs[i].nilai,' ',mhs[i].ket);
end;
writeln ('-------------------------------');
end.
No comments:
Post a Comment