0% found this document useful (0 votes)
22 views3 pages

2D Array Program in Pascal

This document contains a Pascal program that: 1) Reads in values and stores them in a 2D array A with 3 rows and 4 columns. 2) Calculates and prints the sum of all values, the average, the sum of each column, and the sum of each row. 3) Prints the original array again with the row and column sums.

Uploaded by

Chris Pagiatakis
Copyright
© © All Rights Reserved
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)
22 views3 pages

2D Array Program in Pascal

This document contains a Pascal program that: 1) Reads in values and stores them in a 2D array A with 3 rows and 4 columns. 2) Calculates and prints the sum of all values, the average, the sum of each column, and the sum of each row. 3) Prints the original array again with the row and column sums.

Uploaded by

Chris Pagiatakis
Copyright
© © All Rights Reserved
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/ 3

ΠΡΟΓΡΑΜΜΑ ΠΙΝΑΚΕΣ 2 ΔΙΑΣΤΑΣΕΩΝ.

Program pinakes2;
var A:array[1..3,1..4] of integer;
var SS:array[1..4] of integer;
var SG:array[1..3] of integer;
var i,j,s:integer;
mesos:real;
begin
writeln('diabasma');
For i:=1 to 3 do
For j:=1 to 4 do
begin
Writeln('dose ',i,' grammis ',j,' stilis');
Read(A[i,j]);
end;
writeln('ektyposi');
For i:=1 to 3 do
begin
For j:=1 to 4 do
write(A[i,j]:6);
writeln;
end;
Writeln('athroisma mesos oros');
s:=0;
For i:=1 to 3 do
For j:=1 to 4 do
s:=s+A[i,j];
Writeln('to athroisma einai: ', s);
mesos:=s/12;
Writeln('o mesos oros einai: ', mesos:0:2);
Writeln('athroisma sthlon ');
For j:=1 to 4 do
begin
SS[j]:=0;
For i:=1 to 3 do
SS[j]:=SS[j]+A[i,j];
end;
writeln('*****************************');
For i:=1 to 4 do
Write(SS[i]:6);
writeln;
Writeln('athroisma grammon ');
For i:=1 to 3 do
begin
SG[i]:=0;
For j:=1 to 4 do
SG[i]:=SG[i]+A[i,j];
end;
writeln('*****************************');
For i:=1 to 3 do
Writeln(SG[i]:6);
writeln('ektyposi epayximenoy pinaka');
For i:=1 to 3 do
begin
For j:=1 to 4 do
write(A[i,j]:6);
writeln(SG[i]:6);
end;
For i:=1 to 4 do
Write(SS[i]:6);
Writeln(s:6);
End.

You might also like