0

Challenge question

What is the output of this code? #include <iostream> using namespace std; int main() { int x=2,y=4,z=6,q; q=(y,x,z); cout<<q; return 0; }

8th Sep 2020, 6:02 PM
Mohamad Nourigohar
Mohamad Nourigohar - avatar
4 Answers
+ 1
You get answer 6. but with a warning not error...
9th Sep 2020, 4:49 PM
Jayakrishna 🇼🇳
+ 7
Mohamad Nourigohar , you can check this easily by yourself. Put this code in playground and run it.
8th Sep 2020, 6:08 PM
Lothar
Lothar - avatar
+ 3
Always the last value gets assigned to the variable if you are using variables in parentheses like this! So, this means => q = z => q = 6
8th Sep 2020, 6:32 PM
Namit Jain
Namit Jain - avatar
0
i recived an error but in challenge it wants a num
8th Sep 2020, 6:36 PM
Mohamad Nourigohar
Mohamad Nourigohar - avatar