ALGORITMA PENGHITUNGAN MATRIK PERKALIAN
Program Jumlah_matriks;
Uses Wincrt;
Var matA, matB, Matc : Array [1..20, 1..20] of Integer;
I,J,K : Integer ;
brsA , klmA : Integer ;
brsB, klmb : Integer;
Begin
clrscr ;
brsA := 3; klmA :=3 ;
brsB := 3; klmB :=3;
{input elemen matriks A'}
writeln ( ' masukan data matrik A :');
for I := 1 to brsA do
for j := 1 to klmB do
Begin
write ('A[',I,',',J,'] = ');
readln (matA[I,J])
end;
{ Input elemen Matriks A' }
writeln (' Masukan data Matrik B :');
For I := 1 to brsB do
for J := 1 to klmA do
begin
write ('B [',I,',',J,'] =');
readln (matB[I,J] )
end;
writeln ('proses Perkalian matriks....');
write (' tekan ENTER untuk melihat hasilnya....');
For I := 1 to brsA do
for J := 1 to klmB do
BEGIN
matC [I,J] := 0;
For K := 1 to brsB do
matC [I,J] := matC [I,J] + matA [I,K] * matB [K,J];
end;
readln;
clrscr;
{tampil Matriks A}
writeln (' matriks A = ');
for I := 1 to brsA do
Begin
for j := 1 to klmA do
write ( matA[I,J] : 3);
Writeln;
End;
Writeln;
{ tampil matriks B}
writeln (' matriks B= ');
for I := 1 to brsB do
begin
fOR j := 1 to klmB do
write (matB[I,J] : 3);
writeln;
end;
writeln;
{ Tampil Matriks C }
writeln ( ' matriks C = ');
for I := 1 to brsA do
begin
for j := 1 to klmB do
write (matC [I,j] :3);
writeln;
end;
readln;
end.
Jum,banyak,rata-rata bilangan
Program Looping_01;
Uses Wincrt;
Var
Bilangan, Jumlah, i,n: Integer;
Rata_rata : real;
Begin
Jumlah := 0;
i:= 1 ;
Write ( 'MASUKAN BANYAKNYA BILANGAN:');
Readln (N) ;
Writeln;
While i <= N do
Begin
Write (' Bilangan -',i,'=');
readln ( bilangan);
Jumlah := Jumlah + Bilangan;
i := i+1;
End;
rata_rata := Jumlah / N;
Writeln;
Writeln (' BANYAKNYA BILANGAN :',Jumlah : 5);
Writeln (' JUMLAH BILANGAN ;', N:5);
Writeln (' RATA - RATA BILANGAN :', rata_rata :5:2);
End.
Lulus >60
Program menghitung_kelulusan;
Uses Wincrt;
Var
Nilai : Real;
ket : String;
Begin
write ('MASUKAN SEBUAH NILAI:');
Readln (Nilai);
IF Nilai > 60 Then
Ket:= 'lulus'
Else
Ket := ' tidak lulus';
Write (ket);
End.
Bo2t nilai,ket,nilai hurup
Program Jumlah_case;
uses wincrt;
var
Nilai : Integer;
begin
Write('Masukan Nilai :');
readln(nilai);
case nilai of
80..100 : begin
writeln('Juara : 1');
writeln('Hadiah : Mobil');
writeln('Uang Saku : Rp.10.000 000');
end;
70..79 : begin
writeln('Juara : 2');
writeln('Hadiah : Motor');
writeln('Uang Saku : Rp.7.000 000');
end;
60..69 : begin
writeln('Juara : 3');
writeln('Hadiah : Kulkas');
writeln('Uang Saku : Rp.5.000 000');
end;
50..59 : begin
writeln('Juara : 4');
writeln('Hadiah : Mesin Cuci');
writeln('Uang Saku : Rp.5.000 000');
end;
40..49 : begin
writeln('Juara : 5');
writeln('Hadiah : TV');
writeln('Uang Saku : Rp.2.500 000');
end;
0..40 : begin
writeln('Juara : 6');
writeln('Hadiah : Radio Aktif');
writeln('Uang Saku : Rp.2.000 000');
end;
else write('NILAI YANG ANDA MASUKAN SALAH');
end;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar