Study the following program written in a block-structured language: Var x,…

GATE · 1987 · CS · Question 1 subparts

Study the following program written in a block-structured language:

    Var x, y:interger;
    procedure P(n:interger);
    begin
         x:=(n+2)/(n-3);
    end;
    procedure Q
    Var x, y:interger;
    begin
        x:=3;
        y:=4;
        P(y);
        Write(x)                                __(1)
    end;
    begin
        x:=7;
        y:=8;
        Q;
    Write(x);                                   __(2)
    end.

What will be printed by the write statements marked $(1)$ and $(2)$ in the program if the variables are statically scoped?

  1. A.

    $3, 6$

  2. B.

    $6, 7$

  3. C.

    $3, 7$

  4. D.

    None of the above.

Attempted by 12 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…