retagged by
507 views
0 votes
0 votes

retagged by

1 Answer

Best answer
3 votes
3 votes

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

Related questions

0 votes
0 votes
1 answer
3
Shankar Kakde asked Jun 6, 2018
600 views
They have given answer B , but after running this program getting runtime error. Please explain
3 votes
3 votes
5 answers
4
arpit.bagri asked Aug 6, 2023
1,042 views
Why is the output of the below program 36? int main(){ int a = 1; int b = ++a * ++a * ++a; printf("%d", b ); ​​​​ return 0; }