#include<stdio.h>
int main()
{
int x;
int *ptr;
ptr = &x;
*ptr = 0;
printf("x= %d\n", x);
printf("*ptr= %d\n", *ptr);
*ptr += 5;
printf("x= %d\n", x);
printf("*ptr= %d\n", *ptr);
(*ptr)++;
printf("x= %d\n", x);
printf("*ptr= %d\n", *ptr);
return 0;
}
Acc. to precedence brackets will be first simplified and then ++ and therefore it will be post increment :
(*ptr)++ (third portion of question)
value should be 5 as it is post increment operator i.e it will first assign the value and then increment..In this case also it should first assign value and then increment..But answer coming is
6