- 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))
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.
0
thx..!