GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Operators have a same Precedence

#include<stdio.h>

int main() {
    
    int x = 5 ;
    
    printf("%d %d %d",++x,--x,x++) ;
    
    return 0 ;
}

 

Above Program gives the 6 6 5 but i cannot understand how it gives the above result please Explain any one i can use GCC

asked Feb 9, 2017 by Muniyasamy V

1 Answer

it will execute right to left. so 1st  X++ prints 6 then --X also prints 6 then decrement the value by one(5) and last it will print 5 then increment by 1. soutput is 665

answered Feb 9, 2017 by Saurabh Sharma 3

can't understand please explain clearly  ... how --x prints 6 

...