- 1

What is the value of expression in C++:. Y=((t=4,t+3),(t-2,t*3))

What is the value of expression in C++:. Y=((t=4,t+3),(t-2,t*3))

4th Mar 2017, 11:14 AM
mihir sharma
mihir sharma - avatar
2 Respostas
+ 2
Y=12 You can verify it with the following code: #include <iostream> using namespace std; int main() { int t; int Y=((t=4,t+3),(t-2,t*3)); cout << Y; return 0; } The comma operator returns the rightmost value, in this case t*3. Since t was set to 4, the result is 12. t+3 and t-2 don't store the value of the calculation so they have no effect on the result.
4th Mar 2017, 1:18 PM
Tero Särkkä
Tero Särkkä - avatar
0
thx..!
4th Mar 2017, 7:20 PM
mihir sharma
mihir sharma - avatar