0
enter code here

 #include<stdio.h>
 int main()
 {
     char i;


     i='t','f','b','a';                                  
     printf("\ni = %c",i);
     return 0;
 }

in the above code when i assign value to i the first value(t) is assigned to the variable i but if i provide parenthesis around the values ie write i=('t','f','b','a') instead of the one written in the above code the last value ie 'a' gets assigned to the variable i. Can anyone please explain why this happens??

  • 3
    I wouldn't say this is an exact duplicate, although the selected answer explains the question about parens. In case it isn't clear, I wanted to note that in the case without parens, there are 4 different expressions being evaluated. Only the first, `i='t'`, contains the assignment operator. – mstbaum Apr 30 '15 at 15:35
  • what i'd like to ask is that when no parenthesis are used will the expressions after the first one be evaluated??? – Ashwin Arora May 03 '15 at 20:01
  • Yes it will be evaluated, but assigned to nothing. It would be the same as replacing the commas with semi-colons. Note that `'a';` is technically a valid line of code. Useless, but valid. – mstbaum May 07 '15 at 23:12

0 Answers0