For the program segment given below, which of the following are true? program…

PYQ GATE 1993Modified — slightly modified from the official paper; see the solution

For the program segment given below, which of the following are true?

program main (output);

type link = ^data;

data = record

d : real;

n : link

end;

var ptr : link;

begin

new (ptr);

ptr:=nil;

ptr^.d:=5.2;

writeln(ptr^.d)

end.

  1. A.

    The program leads to compile time error

  2. B.

    The program leads to run time error

  3. C.

    The program outputs 5.2

  4. D.

    The program produces error relating to nil pointer dereferencing

  5. E.

    None of the above

Attempted by 30 students.

Sign up free to check your answer

Sign up free

Explore the full course: Zero To Hero

Loading lesson…