If int a=2, and int b=3, what value would the following expression return? a<5 && b<5
a. undefined
b. 1
c. 0
Answers
Answered by
0
Answer:
+1
If int a=3; int b=2; b=a++ cout <<++b,what is the output?
c++
11th March 2017, 3:04 PM
Wis Vaurasi
8 Answers NEW ANSWER
Sort by:
Votes
+14
The output will be 4. Here is how the logic works on your case:
Given :
a = 3
b = 2
Then :
b = a++
which means take a value to b and then increment the a value. so b value is same as a (before the increment), so with that statement, their value become:
b = 3 (same as a before increment)
a = 4 (the value change because we got increment)
Then evaluate the last statement:
++b => this means that we increment the value before we use the value. so in the end.
so,
cout << ++b; // will result: 4
Similar questions