1,275 views

2 Answers

0 votes
0 votes
it is not syntactically correct, it will give comiler error...

if you would have written

int a=(1,2,3);

then a =3 will be initialized because comma operator are left asscociative, finally 3 will be lvalue which will be supllied to rvalue(a)..
0 votes
0 votes
It will give compilation error.

If you write it as

int a;

a=1,2,3

then it will work fine.

Why?

Comma operator has least precedence ( = has higher precedence than, operator)  so it will be like

(a=1), 2, 3;
Output will be 1 in this case. But for the mentioned question it gives Compilation Error.
edited by

Related questions

7 votes
7 votes
3 answers
1
Parshu gate asked Nov 20, 2017
780 views
What is the output of the following program?#include<stdio.h int main() { int array[]={10, 20, 30, 40}; printf(“%d”, -2[array]); return 0; }$-60$$-30$$60$Garbage valu...
2 votes
2 votes
1 answer
2
0 votes
0 votes
1 answer
3