Home / C Programming / Operators and Expressions :: Discussion

Discussion :: Operators and Expressions

  1. What will be the output of the following program?

    void main()

    {

    int a, b, c, d;

    a = 3;

    b = 5;

    c = a, b;

    d = (a, b);

    printf("c=%d d=%d", c, d);

    }

  2. A.

     c=3 d=3

    B.

     c=3 d=5

    C.

     c=5 d=3

    D.

     c=5 d=5

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    The comma operator evaluates both of its operands and produces the value of the second. It also has lower precedence than assignment. Hence c = a, b is equivalent to c = a, while d = (a, b) is equivalent to d = b.


Be The First To Comment