GATE CS 2025 Set 2 | Question 62

Programming & Data Structures › Pointers · NAT · 2 marks · Answer: 111

  1. Question 62Programming & Data Structuresnat2 marks
    Consider the C program:
    int main(){
        int a;
        int arr[5] = {30,50,10};
        int *ptr;
        ptr = &arr[0] + 1;
        a = *ptr;
        (*ptr)++;
        ptr++;
        printf("%d", a + (*ptr) + arr[1]);
        return 0;
    }
    The output of the above program is ___________. (Answer in integer)

    Answer: 111

    Solution

    Answer: 111 arr = {30,50,10,0,0}. ptr = &arr[0]+1 = &arr[1], so a = *ptr = 50. Then (*ptr)++ makes arr[1] = 51. ptr++ now points to &arr[2], where *ptr = 10. Output

More GATE PYQ on Pointers

All GATE CS Programming & Data Structures PYQ →

Attempt GATE CS 2025 Set 2 in real GATE exam mode

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

Create free account →