?
Choose the correct output for the following program.
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);
}
Answer & Solution
Correct Answer:
Option
B
For any comma separated expression the outcome is the right most part.
Join the Discussion
Login to post a comment or share your explanation.
Loginand 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