#include<stdio.h>
int main(){
    int a=5,b=10;
    a=a+b-(b=a);
    printf("\na= %d  b=  %d",a,b); 
    getch();
}

That expression is undefined because you're modifying b and also accessing it for purposes other than to calculate the modification between sequence points. The rule is subtle, so I won't expect you to understand it, but do keep in mind that the expression is wrong and doesn't have predictable behavior.

If you fix the expression to be well defined, it's also easier to understand:

#include <stdio.h>

int main(void)
{
    int a = 5, b = 10;
    
    printf("Before: a = %2d  b = %2d\n", a, b);
    a = a + b;
    b = a - b;
    a = a - b;
    printf("After:  a = %2d  b = %2d\n", a, b);

    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.