Saturday, July 13, 2024

Expressions

 An expression is a combination of symbols that, when evaluated, produces a value. Expressions are typically composed of a mix of operators, operands, and subexpressions.

  • An expression can also consist of a single literal or variable.Thus, 4, 3, and k are each expression. This expression has two subexpressions, 4 and (3 * k). Subexpression (3 * k) itself has two subexpressions, 3 and k. Any expression that is part of a larger expression is called a subexpression. 
  • Subexpressions can be denoted by the use of parentheses. Since a subexpression is an expression, any subexpression may contain subexpressions of its own

Arithmetic Expressions:

  • Expressions that evaluate to a numeric type are called arithmetic expressions.
  • If no parentheses are used, expressions are evaluated based on the rules of operator precedence.

output is 20