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);
}
#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);
}
A. 50, 13, 11, 13
B. 50, 13, 24, 50
C. 13, 10, 24, 50
D. 50, 13, 24, 13
E. 13, 13, 24, 13
Answer: Option B
Solution(By Examveda Team)
For any comma separated expression the outcome is the right most part.
Join The Discussion
Comments ( 4 )
Related Questions on Operators and Expressions
What does the ++ operator do in C when applied to a variable?
A. Decrements by 1
B. Adds 1
C. Doubles the value
D. Leaves it unchanged
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
plz explain this
plz explain this
best