Message from C, C++ talks

July 2019

— Because I don't remember ever seeing such syntax

— I= 0 means assignment of 0 in a variable named i.
int i=0;
if i

Same as
int i=0;

— I=(2,1,0) evaluates to i= 0 bcoz associativity of paranthesis is from left to right .
There is nothing wrong in this syntax

Message permanent page

— Comma operator


but you can do
int a,b,c;
a = b = c = 5;
it will execute c = 5, the result will be 5 and it will be assigned to b, and the result of this will again be 5 and then it will be assigned to a.
in your case 0 is assigned and result (again 0) is casted into bool

— So it's like "execute and forget about it"? in this case 2 and 1 will be just skipped?

— So what is if(i=(1,2,0)) ?

— C

— If Statement

— Do you send these type of questions daily?

— No...I get these questions in my uni's coding club group ... I was having a doubt today

— The answer is C

— I know that pretty well. I was asking for the explanation I guess

— Can you suggest me some sites which will upload some questions about cs or c/c++ daily? Or it doesn't exist?

Message permanent page

— Pretty much that's it