(A) Compiler Error
(B) 0 1 2 2 3
(C) 0 1 2 3 4
(D) 1 2 3 4 5
Explanation: The important things to remember for handling such questions are
1) Prefix ++ and * operators have same precedence and right to left associativity.
2) Postfix ++ has higher precedence than the above two mentioned operators and associativity is from left to right.
We can apply the above two rules to guess all
*ptr++ is treated as *(ptr++)
*++ptr is treated as *(++ptr)
++*ptr is treated as ++(*ptr)
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.