Contents    Page-10    Prev    Next    Page+10   

What is the meaning of a - b + c ?

  • A: (a - b) + c
  • B: a - (b + c)
  • C: doesn't matter
  • D: depends on the language
  • E: depends on the compiler

    Answer: A

    Like most operators, + and - are left-associative. When two left-associative operators of the same precedence are adjacent, the left one is done first.

    A few languages, such as Smalltalk and Python, do not have precedence and proceed left-to-right. However, all mainstream languages use precedence and associativity as described above; a compiler is required to process a language as defined by the language standard.