create program with Pascal (Algol family)

User Generated

NA9214

Programming

Description

We want to play with Pascal (Algol family) a little.



1. Sum array (array -> num)
2. Fill array (num -> array)
3. Equal array (array, array -> boolean)
4. Multiply elems (array, array -> array)
5. Reverse array (array -> array)

Unformatted Attachment Preview

.We want to play with Pascal (Algol family) a little Sum array (array -> num) .1 Fill array (num -> array) .2 Equal array (array, array -> boolean) .3 Multiply elems (array, array -> array) .4 Reverse array (array -> array) .5 ;procedure copyarr(src: array[slb..sub: integer] of real ;)var dst: array[dlb..dub: integer] of real ;var pos: integer begin if (slb dlb) or (sub dub) then ;println("Array bounds do not match!") else for pos := slb to sub do begin ;dst[pos] := src[pos] end ;end :Sample call ;copyarr(globpt, copypt) :Translate and compile your Pascal code p2c pascal.p gcc pascal.c -lp2c a.out/. :Another sample Pascal program with arrays ;program pascal var ;one, too: array[4 .. 8] of real ;cnt: integer ;procedure copyarr(src: array[slb..sub: integer] of real ;)var dst: array[dlb..dub: integer] of real ;var pos: integer begin if (slb dlb) or (sub dub) then begin ;writeln("Array bounds do not match!") end else for pos := slb to sub do begin ;dst[pos] := src[pos] end ;end begin ;one[4] := 10 ;one[5] := 20 ;one[6] := 30 ;one[7] := 40 ;one[8] := 50 ;copyarr(one, too) for cnt := 4 to 8 do begin ;writeln(too[cnt]) end .end
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Hey, here!Programs running... and

Program fill_Array ( input, output );
type
intArray = array [1..5] of integer;
var
i, sum : integer;
numbers : IntArray;
begin
sum := 0;
for i := 1 to 5 do
readln ( numbers[i] );
readln;
for i := 1 to 5 do
writeln ( 'numbers[', i, '] = ', numbers [i] );
readln (i);
end.

Program Double ( input, output );
type
intArray = array [1..5] of integer;
doubleArray = array [1..5] of real;
var
i, sum : integer;
temp : doubleArray;
numbers : intArray;
numbers2 : doubleArray;
begin

end.

for i := 1 to 5 do
begin
readln ( numbers2[i] );
temp[1] := numbers2[i];
numbers[i] := Trunc(temp[1]);
end;
for i := 1 to 5 do
begin
writeln ( 'numbers [', i, '] = ', numbers[i] );
end;
for i := 1 to 5 do
begin
writeln ( 'numbers [', i, '] = ', numbers2[i] );
end;
rea...


Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags