This has been asked in an interview. What is the output of the below snippet?
#include <iostream>
using namespace std;
int main() {
cout << (3,2,1)-(1,2,3) << endl; // in C++ too this prints -2
printf("%d\n",(3,2,1)-(1,2,3)); // prints -2
printf("%d\n",("%d",3,2,1)-(1,2,3)); // prints -2
return 0;
}
By the output I am guessing its (1-3) = -2. But how from (3,2,1)
value 1
is chosen, similarly from (1,2,3)
value 3
is chosen? Am I right in what I am guessing?