Question 42Asked in UGC NET Computer Science, November 2017 (Paper II & III, Selected Questions)

'ptrdata' is a pointer to a data type. The expression *ptrdata++ is evaluated as (in C++):

  1. A*(ptrdata++)
  2. B(*ptrdata)++
  3. C*(ptrdata)++
  4. DDepends on compiler
Show answerHide answer

Correct answer: (A) *(ptrdata++)

Explanation

Postfix ++ has higher precedence than *, so *ptrdata++ is evaluated as *(ptrdata++): the value at ptrdata is used and then the pointer moves to the next location. (*ptrdata)++ would instead increment the value stored at that location.

From UGC NET Computer Science PYQ, November 2017 (Paper II & III, Selected Questions)

This is question 42 of UGC NET Computer Science PYQ, November 2017 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.