Logic Unknown - help needed 04-17-2013, 07:31 PM
#1
i have run these codes
and got the output as
i thought
1stly,++y is evaluated then y increments to 4 and then y++ is evaluated but y does not increments that time ..
so x will show 7... but output i am getting is 8 .. i am using Dev c++ compiler ..
could anyone please tell me what is the actual logic for output = 8 ??
and is there any possibility to get output = 7 if different compiler is used ?
thanks a lot in advance
miling:
Code:
#include<stdio.h>
#include<conio.h>
int main(){
int x,y=3;
x=(y++)+(++y);
printf("%d",x);
getch();
}
and got the output as
Quote:8
i thought
1stly,++y is evaluated then y increments to 4 and then y++ is evaluated but y does not increments that time ..
so x will show 7... but output i am getting is 8 .. i am using Dev c++ compiler ..
could anyone please tell me what is the actual logic for output = 8 ??
and is there any possibility to get output = 7 if different compiler is used ?
thanks a lot in advance
![Confused Confused](https://sinister.ly/images/smilies/set/confused.png)