int main()
{
int x = 3, z ;
z = x / + + x ;
printf ("x = %dz = %d", x , z );
return 0;
}
I thought the output will be x=4 z=0
or x=4 z=1
. But I'm getting x=3 z=1
.
int main()
{
int x = 3, z ;
z = x / + + x ;
printf ("x = %dz = %d", x , z );
return 0;
}
I thought the output will be x=4 z=0
or x=4 z=1
. But I'm getting x=3 z=1
.
Try removing spaces between ++
(increment operator). Use ++x
or ++ x
. Compiler may be interpreting it as +(+x)
, i.e. unary +
operator.
remove spaces in between two pluses
z = x / ++ x ; //will gives z value as 1 always
//except when x=-1 (Floating point exception )
this Might have Undefined Behaviour because Lack of sequence point.
rather than above if you could try like this.
int x = 3, z=3;
printf ("x = %dz = %d", x , z );
z/=(++x); // z/=++x; is also same.
printf ("x = %dz = %d", x , z );