I wrote the following C program to find the output for a+++b
#include<stdio.h>
int main()
{
int a=5, b=2;
printf("%d",a+++b);
}
And I'm getting the output as 7 which is correct according to lexical analysis.
Apart from that I wrote a separate program to find the output for a++ +b
#include<stdio.h>
int main()
{
int a=5, b=2;
printf("%d",a++ + b);
}
For the above program again I'm getting output as 7 (which is again correct according to lexical analysis)
But when I wrote a program to print the outputs for both a+++b and a++ +b I'm getting different outputs
#include<stdio.h>
int main()
{
int a=5, b=2;
printf("%d",a+++b);
printf("\n%d",a++ + b);
}
The output is 7 for a+++b (which is correct) and 8 for a++ +b (which is wrong).
Can anyone point out the error in the third program?