0% found this document useful (0 votes)
35 views4 pages

5.2 Program Jumlah Matrik Source Code

This document contains the source code for two programs. The first program calculates the sum and average of values in a 2D array representing a matrix. It prompts the user to enter the number of rows and columns, inputs the values, displays the matrix with sums and averages. The second program defines a record type for students with fields for ID, name, grade, and letter grade. It inputs data for multiple students into an array of records, calculates a class average, and displays the student data and average.

Uploaded by

fienka_mareta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views4 pages

5.2 Program Jumlah Matrik Source Code

This document contains the source code for two programs. The first program calculates the sum and average of values in a 2D array representing a matrix. It prompts the user to enter the number of rows and columns, inputs the values, displays the matrix with sums and averages. The second program defines a record type for students with fields for ID, name, grade, and letter grade. It inputs data for multiple students into an array of records, calculates a class average, and displays the student data and average.

Uploaded by

fienka_mareta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

5.

2 Program Jumlah Matrik SOURCE CODE:


Program Jumlah_Matrik; Uses Crt; Var z,x,c,v,b,n,total : integer; rata : real; nilai : array [1..100,1..100] of integer; Begin Clrscr; Write('Masukkan banyak baris :'); Readln(z); Write('Masukkan banyak kolom :'); Readln(x); for c:= 1 to z do Begin for v := 1 to x do Begin Write('Data ke- ',c,',',v,' : '); Readln(nilai[c][v]); end; end; Writeln('Tampilan matrik beserta jumlah dan ratarata'); Writeln(' Matrik Jumlah9 Rata'); for b:= 1 to z do Begin total:=0; for n:= 1 to x do Begin total:=total+nilai[b][n]; Write(nilai[b][n]:4); end; rata:=total/x; Write(' ',total); Write(' ',rata:0:2); Writeln; end; Readln; end.

OUT PUT :

5.3 Program Array of Record


SOURCE CODE
Program Nilai_Mahasiswa; Uses Crt; type mhs=record nim:integer; nama:string; nilai:integer; NH:char; end; Var datamhs:array [1..100] of mhs; q,i,jml:integer; rata:real; Begin Clrscr; Write('Masukkan jumlah mahasiswa (maks 100): '); Readln(q);

Writeln('Input data mahasiswa'); jml:=0; for i:=1 to q do Begin Writeln('Data mahasiswa ke- ',i); Write('Nim : '); Readln(datamhs[i].nim); Write('Nama : '); Readln(datamhs[i].nama); Write('Nilai : '); Readln(datamhs[i].nilai); jml:=jml+datamhs[i].nilai; if datamhs[i].nilai>80 then datamhs[i].NH:='A' else if datamhs[i].nilai>70 then datamhs[i].NH:='B' else if datamhs[i].nilai>60 then datamhs[i].NH:='C' else datamhs[i].NH:='E'; end; rata:=jml/q; {menampilkan data mahasiswa} Writeln; Writeln('Data mahasiswa yang ada'); for i:=1 to q do Writeln(datamhs[i].nim,', ',datamhs[i].nama,', ',datamhs[i].nilai,', ',datamhs[i].NH); Writeln; Writeln('Rata-rata nilai : ',rata:3:2); Readln; end.

OUT PUT

You might also like