in Programming in C retagged by
505 views
0 votes
0 votes

in Programming in C retagged by
505 views

3 Comments

Output is 11 3

How it is calculated?
0
0
0
0
simply go to comma operator wikipedia. You will get more examples there with nice explanation
0
0

1 Answer

3 votes
3 votes
Best answer

x = (3, 2, 11); -------- Comma work as operator

'()' operator has higher precedence than '='. So , firstly, bracket operator is evaluated. '()' operator is operated from left to right. but it is always the result of last that gets assigned.

y = 3, 2, 11; -------- Comma work as seperator

'=' operator has higher precedence than ',' operator. so 'y' gets initialized by '3'. '2' and '11' are just constant expression. so have no effect .

Ref: https://stackoverflow.com/questions/17251584/difference-between-int-i-1-2-3-and-int-i-1-2-3-variable-declaration-with

Ref:- https://www.geeksforgeeks.org/a-comma-operator-question/

edited by

2 Comments

@Mizuki,

yes, your answer is correct, i just added some other reference

0
0

@Shaik Masthan

Thank you for edits.

0
0

Related questions