GATE CS 2024 Set 2 | Question 36

Programming & Data Structures › Pointers · MCQ · 2 marks · Answer: B

  1. Question 36Programming & Data Structuresmcq2 marks
    double a[2]={20.0,25.0},*p,*q;
    p=a; q=p+1;
    printf("%d,%d",(int)(q-p),(int)(*q-*p));
    Output?
    • A.
      4,8
    • B.
      1,5
      ✓
    • C.
      8,5
    • D.
      1,8

    Answer: B

    Solution

    Answer: (B) 1,5 q-p is pointer difference in units of elements . *q-*p = 25.0-20.0 = 5.0, cast to int . Output: "1,5".

More GATE PYQ on Pointers

All GATE CS Programming & Data Structures PYQ →

Attempt GATE CS 2024 Set 2 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →