+ 1
Can anyone explain this question?
#include<iostream> using namespace std; int main() { int i=4, j=5, k=6, r; r= ( i, j, k); cout<<r; return0; } Here, in this question I thought I would make some 'error', but the real answer is '6' Can anyone explain me how the answer comes 6 instead of giving 'error' Please help.
3 odpowiedzi
+ 2
Amul Gaurav
here in r = (i, j, k) we are using comma operator
comma (,) can be used in 2 ways
1 - a separator
2 - an operator
So here using an operator which will not give error and print last value
If you do like this:
int i = 1, 2, 3;
Here we are using a comma separator which will give error
+ 2
Now I get that, thanks a lot for your help guys
+ 1
Have you tried running the code on sololearn?
It outputs 6 but gives a warning.