+ 4
[Solve]Who use code block for c++ programming, I need help ?
increment does not works as it should
4 odpowiedzi
+ 3
Zack The Gamer it's desired behaviour..
refer below:
int x = 1;
int y = ++x;
int a = 1;
int b = a++;
with above for line executed, updated value will be below :
x , y and a will have 2... b will have 1...
why it is so?
because int y = ++x do below thing :
x = x + 1;
int y = x;
and in case of int b = a++;
int b = a;
a = a + 1;
if individually you do ++ , for example int z = 1; ++z or z++ ; both will be z = z+1;
+ 3
I write int a = 1 , int b = 1 , ++a //should be 2 , b++ // should be 1 . but when I cout value of a and b.. I got 2 for both . I am using code block
+ 3
thank you, so for people who come to seek answer and dont understand what Ketan are sayin .
Its basically just let both variable related . Which means a = 1 and b = ++a is the solution
+ 1
b is increasing after your” b++” per 1 (so, when you use „b++“ is equel to „b=b+1“)
also when you need to block one string of your code, you can use “//“ and when you have more than one string to comment you can use this: /* smth to comment */