Skip to content
Related Articles

Related Articles

C | Operators | Question 4
  • Difficulty Level : Basic
  • Last Updated : 05 Jan, 2013
 
#include <stdio.h>

int main()
{
    int i;
    
    i = 1, 2, 3;
    printf("%d", i);
    
    return 0;
}

(A) 1
(B) 3
(C) Garbage value
(D) Compile time error


Answer: (A)

Explanation: Comma acts as an operator. The assignment operator has higher precedence than comma operator. So, the expression is considered as (i = 1), 2, 3 and 1 gets assigned to variable i.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :