Question: 1 . Consider the following code: program MAIN; var i : integer; var a : array [ 1 . . 5 ] of integer; procedure

1. Consider the following code:
program MAIN;
var i : integer;
var a : array[1..5] of integer;
procedure SUB(x : integer);
{x++; a[i] := a[i-2]+3; i++; x++; a[i] := a[i+1]+ x; x++; i++; a[i] := a[i]+ x;}
(end SUBPROG)
{a[1] :=2; a[2] :=3; a[3] :=4; a[4] :=5; a[5] :=6; i :=3;
call SUB(a[i]);
print (a[1..5]);
}
(end MAIN)
Note: Assume that all un-initialized variables have the value zero.
Note: For each question below (a) through (f) work must accompany your solution.
Show in detail the trace you used to arrive at each of the answers.
(4 pts)
(a) What is the program output assuming that the parameter is passed by value?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!