Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок+ 2
a=3,b=2 ,b=a++,cout <<++b; How 4?
8 ответов
+ 6
You're setting B to A++, this means you're setting B to 3, as it is a post-increment. A then becomes 4 due to the post-increment.
You then print out ++B, which is a pre-increment, so it increments before printing out it's value. So B becomes 4, thus the output is 4.
+ 2
dont fool guys...
b++ doesnt mean b+1+1...
b++ is post increment..
so when b++ is execaute its remains b and in next turn it becomes b+1 and if it is pre-increment then before execauting value of b it was incremennted and use
like...
6++ = 6,7,8,9.... in loop
++6 = 7,8,9,.... in loop
+ 1
in this example...
first b=a++..
here it ia post-increment..
so b=3 and after that cout<<++b so here it is preincrement...
so the value will be 4
+ 1
a++ evaluates to the old value of a, and increments a.
++b increments b and evaluates to the new value of b.
Only after this code is evaluated will a be saved in the memory incremented.
I recommend changing b = ++a; to see how it changes the code.
0
I guess one + specifies +1 so answer is 4
0
thanks guys
- 2
if n=3. then n+ = n+1.
similarly n++ = n+1+1
3+1+1=4.
u can take this eg.
- 2
++b
=1+1+2=4.
do not forget to make my answer helpful