ExamVeda
Login
Home
Operators and Expressions
?

Choose the correct output for the following program.
#include<stdio.h>
void main()
{
   int a=10, b=11, c=13, d;
   d = (a=c, b+=a, c=a+b+c);
   printf("%d %d %d %d", d, a, b, c);
}

Answer & Solution
Correct Answer: Option B

For any comma separated expression the outcome is the right most part.

Examveda
Question posted by Examveda
Community

Join the Discussion

4 Comments
Pãrïmálå Mådâkā
Pãrïmálå Mådâkā 9 years ago
a=c then it will become a=13
and b+=a is solved as b+a then it will become 11+13=24
after that c=a+b+c then c=13+24+13=50
when comma operator is there last expression is considered as the value of d.
then the output for printf("%d%d%d%d",d,a,b,c) is 50 13 24 50
Santosh Naidu
Santosh Naidu 9 years ago
plz explain this
Santosh Naidu
Santosh Naidu 9 years ago
plz explain this
Riti Thakur
Riti Thakur 11 years ago
best