c - Please Explain Comma Operator in this Program -



c - Please Explain Comma Operator in this Program -

please explain me output of program:

int main() { int a,b,c,d; a=10; b=20; c=a,b; d=(a,b); printf("\nc= %d",c); printf("\nd= %d",d); }

the output getting is:

c= 10 d= 20

my uncertainty "," operator here? compiled , ran programme using code blocks.

the , operator evaluates series of expressions , returns value of last.

c=a,b same (c=a),b. why c 10

c=(a,b) assign result of a,b, 20, c.

as mike points out in comments, assignment (=) has higher precedence comma

c comma

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -