0
SYNTAX PROGRAM TABEL MATEMATIKA
Posted by Unknown
on
07.06
Sekarang saya mau ngasih contoh syntax pascal yang ARRAY :D check this one out !!!
PROGRAM TABELMATEMATIKA;
USES WINCRT;
VARI,N:INTEGER;
X,Y:ARRAY[1..10] OF INTEGER;
TAMBAH,KALI,KURANG,BAGI:REAL;
BEGINWRITE('JUMLAH DATA ?');READLN(N);
FOR I:=1 TO N DO
BEGIN
WRITELN('INPUT DATA KE-',I);
WRITELN('___________________');
WRITE('NILAI X : ');READLN(X[I]);
WRITE('NILAI Y : ');READLN(Y[I]);
END;
WRITELN(' TABEL OPERASI MATEMATIKA ');
WRITELN('_________________________________________');
WRITELN('NO. X Y X+Y X*Y X-Y X/Y '); WRITELN('_________________________________________');
FOR I:=1 TO N DO
BEGIN
TAMBAH:=X[I]+Y[I];
KALI:=X[I]*Y[I];
KURANG:=X[I]-Y[I];
BAGI:=X[I]/Y[I];
WRITELN(I,' ',X[I],' ',Y[I],' ',TAMBAH:6:0,' ',KALI:6:0, ' ',KURANG:6:0,' ',BAGI:6:0);
END;
WRITELN('_________________________________________');
END.
Contoh yang kedua :
program mahasiswa;
uses wincrt;
var
I,N:integer;
NIM:array[1..10] of string;
NAMA:array[1..10] of string;
TUGAS,QUIS,UTS,UAS:array[1..10] of integer;
NA:real;
GRADE:char;
begin
write('Jumlah Data ? ');readln(N);
for I:=1 to N do
begin
write('Input data ke-',I);
write('___________________________');
write('Nama Mahasiswa : ');Readln(nama[i]);
write('NIM Mahasiswa : ');Readln(NIM[i]);
write('TUGAS : ');readln(TUGAS[i]);
write('QUIZ : ');readln(QUIS[i]);
write('UTS : ');readln(UTS[i]);
write('UAS : ');readln(UAS[i]);
end;
clrscr;
writeln('DAFTAR NILAI MAHASISWA');
writeln('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
writeln('No. NIM NAMA TUGAS QUIS UTS UAS NA GRADE');
writeln('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
for I:= 1 to N do
begin
NA:=0.2*tugas[i]+0.15*quis[i]+0.25*uts[i]+0.4*uas[i];
if (na>=86) and (na>=100) then
grade:='A'
else if (na>=71) and (na>=85) then
grade:='B'
else if (na>=61) and (na>=70) then
grade:='C'
else if (na>=46) and (na>=60) then
grade:='D'
else if (na>=17) and (na>=45) then
grade:='E'
end;
writeln(I,' ',NIM[i],' ',NAMA[i],' ',TUGAS[i],' ',QUIS[i],' ',UTS[i],' ',UAS[i]);
end.
Semoga bermanfaat :)
PROGRAM TABELMATEMATIKA;
USES WINCRT;
VARI,N:INTEGER;
X,Y:ARRAY[1..10] OF INTEGER;
TAMBAH,KALI,KURANG,BAGI:REAL;
BEGINWRITE('JUMLAH DATA ?');READLN(N);
FOR I:=1 TO N DO
BEGIN
WRITELN('INPUT DATA KE-',I);
WRITELN('___________________');
WRITE('NILAI X : ');READLN(X[I]);
WRITE('NILAI Y : ');READLN(Y[I]);
END;
WRITELN(' TABEL OPERASI MATEMATIKA ');
WRITELN('_________________________________________');
WRITELN('NO. X Y X+Y X*Y X-Y X/Y '); WRITELN('_________________________________________');
FOR I:=1 TO N DO
BEGIN
TAMBAH:=X[I]+Y[I];
KALI:=X[I]*Y[I];
KURANG:=X[I]-Y[I];
BAGI:=X[I]/Y[I];
WRITELN(I,' ',X[I],' ',Y[I],' ',TAMBAH:6:0,' ',KALI:6:0, ' ',KURANG:6:0,' ',BAGI:6:0);
END;
WRITELN('_________________________________________');
END.
Contoh yang kedua :
program mahasiswa;
uses wincrt;
var
I,N:integer;
NIM:array[1..10] of string;
NAMA:array[1..10] of string;
TUGAS,QUIS,UTS,UAS:array[1..10] of integer;
NA:real;
GRADE:char;
begin
write('Jumlah Data ? ');readln(N);
for I:=1 to N do
begin
write('Input data ke-',I);
write('___________________________');
write('Nama Mahasiswa : ');Readln(nama[i]);
write('NIM Mahasiswa : ');Readln(NIM[i]);
write('TUGAS : ');readln(TUGAS[i]);
write('QUIZ : ');readln(QUIS[i]);
write('UTS : ');readln(UTS[i]);
write('UAS : ');readln(UAS[i]);
end;
clrscr;
writeln('DAFTAR NILAI MAHASISWA');
writeln('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
writeln('No. NIM NAMA TUGAS QUIS UTS UAS NA GRADE');
writeln('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
for I:= 1 to N do
begin
NA:=0.2*tugas[i]+0.15*quis[i]+0.25*uts[i]+0.4*uas[i];
if (na>=86) and (na>=100) then
grade:='A'
else if (na>=71) and (na>=85) then
grade:='B'
else if (na>=61) and (na>=70) then
grade:='C'
else if (na>=46) and (na>=60) then
grade:='D'
else if (na>=17) and (na>=45) then
grade:='E'
end;
writeln(I,' ',NIM[i],' ',NAMA[i],' ',TUGAS[i],' ',QUIS[i],' ',UTS[i],' ',UAS[i]);
end.
Semoga bermanfaat :)