Examveda
Examveda

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);
}

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.


This Question Belongs to C Program >> Operators And Expressions

Join The Discussion

Comments ( 4 )

  1. Pãrïmálå Mådâkā
    Pãrïmálå Mådâkā :
    6 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

  2. Santosh Naidu
    Santosh Naidu :
    7 years ago

    plz explain this

  3. Santosh Naidu
    Santosh Naidu :
    7 years ago

    plz explain this

  4. Riti Thakur
    Riti Thakur :
    8 years ago

    best

Related Questions on Operators and Expressions