GATE CS 2025 Set 2 | Question 62
Programming & Data Structures › Pointers · NAT · 2 marks · Answer: 111
- Question 62Programming & Data Structuresnat2 marksConsider the C program:
The output of the above program is ___________. (Answer in integer)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; }Answer: 111
Solution
Answer: 111arr = {30,50,10,0,0}.ptr = &arr[0]+1 = &arr[1], soa = *ptr = 50. Then(*ptr)++makesarr[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 →