0
++x and x=x+1 aren't equal??
9 Respostas
+ 1
yes is equal, the first exp is the most compact while the second exp is complete
+ 1
++x will increase and then consider the expression but it not with the case of x+=1
0
that depends on the way it used.
0
Depends, how you use them.
0
they are equal but there is a different between preincrement and postincrement
0
x++ and x+=1 are not equal while printing, but ++x and x+=1 are equal
0
++i or i++or i=i+1 or i+=1 have the same practical effect "in a bubble", by that I mean that you can use them interchangeably if you're not assigning i+1 to any other variable, or using i+1 on the same line where you increment i. the difference between i++ and ++i is that ++i increments first, then uses the new value, and i++ does the opposite. there others have the same effect regardless of how you write them.
0
on another note, both for(i=0;i<5;i++) and for(i=0;i<5;++i) have the same effect, but b=i++; does not have the same effect as b=++i;
- 2
Both are same, but while printing it makes lot of difference.