C | Operators | Question 4
#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
Recommended Posts:
- Operators in C | Set 2 (Relational and Logical Operators)
- C | Operators | Question 9
- C | Operators | Question 23
- C | Operators | Question 10
- C | Operators | Question 22
- C | Operators | Question 24
- C | Operators | Question 26
- C | Operators | Question 27
- C | Operators | Question 8
- C | Operators | Question 7
- C | Operators | Question 16
- C | Operators | Question 6
- C | Operators | Question 27
- C | Operators | Question 2
- C | Operators | Question 3



