According to the precedence table the precedence of postfix operator is higher than prefix operator, so the output of the following code should be 2 as first si++ is evaluated then ++si is incremented. So, the output should be 4-2 which is 2. But the actual output is 0. Can anyone explain why so?
#include <stdio.h>
int main()
{
short int si = 2;
short int a = ++si - si++;
printf("%d ", a);
return 0;
}
Output:
0
Aucun commentaire:
Enregistrer un commentaire