What is a full expression in C?

前端 未结 3 2020
隐瞒了意图╮
隐瞒了意图╮ 2021-02-19 23:11

I study C language from \"C Primer Plus\" book by Stephen Prata and it came to the point :

\"A full expression is one that’s not a subexpression of a lar

3条回答
  •  野的像风
    2021-02-19 23:49

    An operator along with its operands constitute a simple expression which is called the full expression.

    A compound expression can be formed by using simpler expressions as operands of the different types of operators. The evaluation order of the operators in an expression will be determined by the operator precedence rules followed in the C language.

    A sub-expression is not just any part of a larger expression.

    Consider:

    2 * 3 + 4 * 5
    

    Here 3+4*5 is not a sub-expression.

    The full expression parses as

    (2 * 3) + (4 * 5)
    

    and so the direct sub-expressions are 2*3 and 4*5.

    Each of those again parse as compositions of smaller things, with 2*3 composed of the sub-expressions 2 and 3, and with 4*5 composed of the sub-expressions 4 and 5.

    These sub-expressions of sub-expressions are indirect sub-expressions of the original full expression, so that in total it has these sub-expressions: 2*3, 4*5, 2, 3, 4 and 5.

    While e.g. 3+4*5 is not a sub-expression.

提交回复
热议问题