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

GATE · 1993 · CS · Question 7 subpartsModified — 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 18 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…