1

What would be the output of following program and why? I am not able to understand the logic behind it.

main()
{

    int x = 10;
    int y = 5;
    printf("%d",(y,x));
    return 0;

}
elixenide
  • 44,308
  • 16
  • 74
  • 100
jerrytom
  • 17
  • 2
  • The output would be `10` Because `printf` statement is `parsed right to left` so when %d is occurred it would print value of rightmost integer variable. In this case it would be `x` – user3368369 Mar 15 '14 at 17:50
  • 2
    This answer is right but the explanation is wrong. It's not the printf() statement that's parsed right to left, but the comma operator that's evaluated left to right ("last value wins"). – mfro Mar 15 '14 at 17:53

0 Answers0