1. Buatlah program matriks !
Program Matriks;
uses wincrt;
var tabel:array[1..3,1..2] of integer;
i,j:integer;
begin
tabel [1,1]:=50;
tabel [1,2]:=55;
tabel [2,1]:=21;
tabel [2,2]:=26;
tabel [3,1]:=10;
tabel [3,2]:=1;
for i:=1 to 3 do
begin
for j:=1 to 2 do
write(tabel[i,j],' ');
writeln;
end;
end.
2. Buatlah program penjumlahan matriks !
Program Penjumlahan_Matriks;
uses wincrt;
var a,b,c:array[1..25,1..25] of integer;
i,j,k,l,m,n:byte;
begin
writeln(' PENJUMLAHAN MATRIKS ');
writeln(' ================= ');
write ('Baris Matriks Pertama = Baris Matriks Kedua = ');readln(m);
write ('Kolom Matriks pertama = Kolom Matriks Kedua = ');readln(n);
writeln;
writeln('Komponen matriks yang pertama');
for i:=1 to m do
begin
for j:=1 to n do
begin
write ('Nilai[',i,',',j,']=');readln(a[i,j]);
end;
writeln;
end;
writeln('Komponen matriks yang kedua');
for i:=1 to m do
begin
for j:=1 to n do
begin
write ('Nilai[',i,',',j,']=');readln(b[i,j]);
end;
writeln;
end;
for i:=1 to m do
begin
for j:=1 to n do
begin
c[i,j]:=a[i,j]+b[i,j];
end;
end;
writeln;
writeln('Hasil Penjumlahan Matriks');
writeln;
for i:=1 to m do
begin
writeln;
for j:=1 to n do
write(c[i,j]:4);
end;
end.
3. Buatlah program memasukkan nilai matriks !
Program Memasukkan_Nilai_Matriks;
uses wincrt;
var tabel:array[1..100,1..100] of integer;
i,j:integer;
begin
write('masukkan baris = ');readln(i);
write('masukkan kolom = ');readln(j);
writeln('matriks anda berukuran = ',i,'x',j);
for i:=1 to i do
for j:=1 to j do
begin
write('nilai : ','');readln(tabel[i,j]);
end;
writeln;
writeln('Matriksnya:','');
for i:=1 to i do
begin
for j:=1 to j do
write(tabel[i,j]:3);writeln;
end;
end.
4. Buatlah program menghitung rata-rata !
Program Menghitung_Rata_Rata;
uses wincrt;
var x:array[1..10] of integer;
i,n:integer;
jumlah,u:real;
begin
write('berapa kali data yang anda masukkan ? ');readln(n);
for i:=1 to n do
begin
write ('masukkan data = ');readln(x[i]);
end;
begin
clrscr;
for n:= 1 to i do
writeln('data = ' ,(x[n]));
end;
jumlah:=0;
for i:=1 to n do
jumlah:=jumlah+(x[i]);
u:=jumlah/n;
writeln ('u = ' ,u:2:2);
end.
Tidak ada komentar:
Posting Komentar