0

++a?

How work Int a =10, b; b = ++a+a; cout << b; I don't remember lessons about ++a, only a++.

4th Feb 2022, 12:20 PM
ŠŠ½Š“рŠµŠ¹
ŠŠ½Š“рŠµŠ¹ - avatar
6 Answers
+ 3
int a=10; cout<< ++a + a<<endl; // 11+11=22, increments value first then uses it value next, cout<<a; //11 a=10; cout<< a++ + a <<endl; //10+11=21 , first it's value uses in print and increments next. cout<<a; //11 edit: if there is sequence point issue, then output is compiler dependent because output is undefined by standards.
4th Feb 2022, 12:39 PM
Jayakrishna šŸ‡®šŸ‡³
+ 1
++a means that value of a is changed by one before rest of the line runs. Your code means the same as int a=10,b; a++; b=a+a; cout<<b;
4th Feb 2022, 12:31 PM
Bartek
4th Feb 2022, 12:37 PM
Bartek
0
Sorry, don't understand
4th Feb 2022, 12:34 PM
ŠŠ½Š“рŠµŠ¹
ŠŠ½Š“рŠµŠ¹ - avatar