2 votes 2 votes What will be printed by following $\text{C}$ code? int a[7] = {0, 1, 2, 3, 4, 5, 6}; int *p = &a[3]; p += 2; *p += 2; printf("%d", *p++); $6$ $7$ $8$ $9$ Programming in C goclasses2024-iiith-mock-5 goclasses programming programming-in-c pointers 1-mark + – GO Classes asked Apr 30, 2023 • retagged Apr 29 by Lakshman Bhaiya GO Classes 304 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
3 votes 3 votes $\textsf{p}$ points to $3.$ $\textsf{p += 2;}$ will make p point to $5$ $\textsf{*p += 2;}$ will make $\textsf{a[5]}$ as $7.$ $\textsf{*p++;}$ here postfix $\textsf{++}$ has higher precedence so we will do $\textsf{p++}$ first. But since it is postfix hence result will not be reflected in same line. Now we do $\textsf{*p}$ which is same as $7.$ In the next line, $\textsf{p}$ points to $\textsf{a[6]}.$ GO Classes answered Apr 30, 2023 GO Classes comment Share Follow See 1 comment See all 1 1 comment reply Rudra Joshi commented May 3 reply Follow Share In the beginning p will point to 2 as &a[3] will give 2 as output I think so 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes // FOR simplicity #include <stdio.h>int main(){ int a[7] = {0, 1, 2, 3, 44, 50, 64};int *p = &a[3];p += 2;*p += 2;printf("%d ", *p++);printf("%d", *p); return 0;} o/p --> 52 64 naval answered Apr 30 naval comment Share Follow See all 0 reply Please log in or register to add a comment.