Computer Science, asked by Nousher, 10 months ago

#include <stdio.h>
int main()
{
int a=10, b= 6;
printf("%d\n%d\n", a, b) ;
a= a+b-(b=a);
printf ("%d\n%d", a,b);
}
output :
10
6
6
10
can u explain this condition pls
a=a+b-(b=a) ​

Answers

Answered by mohammads
1

Answer:

The expressions are evaluated from left to right

Explanation:

First a=a+b

16-(b=a) is evaluated

when the compiler gets the bracket it evaluates the expression and assigns the value of a to b which is 10

                b=a

therefore b=10              ----->exp1

So the expression becomes

a=10+6-10       ---->exp2

therefore

now a=6 and b=10

Similar questions