- 1
Int a=3,int b=2; b=a++; cout<<++b;
What is output and explain by another example?
2 Answers
+ 2
Output is 4 for your question.
.
.
int a=4;
int b=5;
b=++a; // a incremented by one and then assign to b .now b value is 5, a value is 5
a=b--; //b value is assign to a and then b value is decreased by 1.now a value is 5, b value is 4
cout<<a;
cout<<b;
output is 5
4
+ 2
Learn this
First b become 3 then 3 increament & become 4 , so output will be 4 https://www.sololearn.com/learn/CPlusPlus/1610/