Skip to content
Related Articles

Related Articles

C | Pointer Basics | Question 16
  • Difficulty Level : Medium
  • Last Updated : 15 Sep, 2013




#include <stdio.h>
int main()
{
    int arr[] = {1, 2, 3, 4, 5};
    int *p = arr;
    ++*p;
    p += 2;
    printf("%d", *p);
    return 0;
}

(A) 2
(B) 3
(C) 4
(D) Compiler Error


Answer: (B)

Explanation: The expression ++*p is evaluated as “++(*p)” . So it increments the value of first element of array (doesn’t change the pointer p).

When p += 2 is done, p is changed to point to third element of array.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :