Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following program. Give the three numbers printed in the case that

ID: 3792648 • Letter: C

Question

Consider the following program. Give the three numbers printed in the case that Y is transmitted to P 1) by value, 2) by result, 3) by value-result, 4) by reference, and 5) by name. Assumption: All integers will by default have value 0 when being declared.

program main()

   var Y: integer;

   procedure P (X: integer);

        begin -------- begin of procedure P

        X := X+1;

        Write (X, Y)

        end ---------- end of procedure P

   begin -------------begin of program

   Y :=2;

   P(Y);

   write (Y)

   end ---------- end of program

Explanation / Answer

CALL by Reference : 3 3 3

CALL By Value- Result : 3 3 3

CALL by Name : 3 3 3

CALL by Value : 3 2 2

CAll by Result : 3 3 2