contoh program input data dalam pascal
Ini ada contoh program input data
Program Input_Data;
uses crt;
const
garis = '--------------------------------------------------------------';
var
n,i,bar : integer;
nil1,nil2 : Array [1..100] of 0..100;
npm : Array [1..100] of string[8];
nama : array [1..100] of string [15];
jum : real;
tl : char;
begin
clrscr;
write ('Batas Max data 100 orang,isi berapa data coy :');
readln(n);
for i := 1 to n do
begin
clrscr;
gotoxy (30,4+1); write ('Data Ke-:',i:2);
gotoxy (10,5+i); write ('NPM :'); readln (npm[i]);
gotoxy (10,6+i); write ('Nama :'); readln (nama[i]);
gotoxy (10,7+i); write ('Nilai 1 :'); readln (nil1[i]);
gotoxy (10,8+i); write ('Nilai 2 :');readln (nil2[i]);
end;
clrscr;
gotoxy (5,4); write (garis);
gotoxy (5,5); write ('No');
gotoxy (9,5); write ('NPM');
gotoxy (18,5); write ('Nama');
gotoxy (34,5); write ('Nilai1');
gotoxy (41,5); write ('Nilai2');
gotoxy (49,5); write ('Rata-rata');
gotoxy (60,5); write ('Abjad');
gotoxy (5,6); write (garis);
bar := 7;
for i := 1 to n do
begin
jum := (nil1[i]+nil2[i])/2;
if jum >= 90 then tl := 'A'
else
if jum >=80 then tl := 'B'
else
if jum >= 60 then tl := 'C'
else
if jum = 50 then tl :='D'
else
tl := 'E';
gotoxy (5,bar); writeln (i:2);
gotoxy (9,bar); writeln (npm[i]);
gotoxy (18,bar); writeln (nama[i]);
gotoxy (34,bar); writeln (nil1[i]:4);
gotoxy (41,bar); writeln (nil2[i]:4);
gotoxy (50,bar); writeln (jum:5:1);
gotoxy (62,bar); writeln (tl);
bar := bar +1;
end;
gotoxy (5,bar+1);writeln(garis);
readln;
end.
program kali_matriks;
uses crt;
const ab =3 ; ak=2; bb=2; bk=3;
type ma=array [1..ab,1..ak]of integer;
mb=array [1..bb,1..bk]of integer;
mc=array [1..ab,1..bk]of integer;
var i,j,k :integer;
a:ma; b:mb; c:mc;
begin clrscr;
{isi matriks a}
for i:=1 to ab do begin
for j:= 1to ak do begin
write('A[ ',i,' ',j,'] =');readln(a[i,j]);
end;
end;
{isi matriks b}
for i:=1 to bb do begin
for j:= 1to bk do begin
write('B[ ',i,' ',j,'] =');readln(b[i,j]);
end;
end;
{perkalian matriks a&b}
for i:=1 to ab do begin
for j:= 1to bk do begin
for k:= 1 to ak do begin;
c[i,j]:=c[i,j] + (a[i,k] * b[k,j]) ;
end;
end;
end;
for i:=1 to ab do begin
for j:= 1to bk do begin
writeln('C[ ',k,' ',k,'] =',c[i,j]);
end;
end;
end.
program tes_reco;
uses crt;
type Mahasiswa = record
Nim :longint;
Nama :string;
Kelas :char;
Alamat :string;
end;
const a=50;
var M : array [1..a] of Mahasiswa; i,n : integer;
begin clrscr;
gotoxy(2,2) ;write ('masukkan jumlah Mahasiswa: '); readln (n);
i:=1; repeat
gotoxy(2,3); write ('Mahsiswa Ke : ',i);
gotoxy(2,4); write ('Nim: '); readln(M[i].Nim);
gotoxy(2,5); write ('Nama : ');readln(M[i].Nama);
gotoxy(2,6); write ('kelas : ');readln(M[i].Kelas);
gotoxy(2,7); write ('Alamat : ');readln(M[i].Alamat); inc(i);
until (i>n);
writeln ;
writeln ('-----------------------------------------------------------------------------------');
writeln ('No Nim Nama Kelas Alamat');
writeln ('-----------------------------------------------------------------------------------');
for i:=1 to n do begin
gotoxy(1,11+i); writeln (i);
gotoxy(3,11+i); writeln (M[i].Nim);
gotoxy(18,11+i); writeln(M[i].Nama);
gotoxy(30,11+i); writeln(M[i].Kelas);
gotoxy(33,11+i); writeln(M[i].Alamat);end;
gotoxy(0,12+i);
writeln ('--------------------------------------------------------------------------------------'); readkey;
end.
0 Response to "contoh program input data dalam pascal"
Post a Comment