Given the following prefix expression : * + 3 + 3 ↑ 3 + 3 3 3 What is the…

2016

Given the following prefix expression :

* + 3 + 3 ↑ 3 + 3 3 3

What is the value of the prefix expression ?

  1. A.

    2178

  2. B.

    2199

  3. C.

    2205

  4. D.

    2232

Attempted by 254 students.

Show answer & explanation

Correct answer: C

Solution: Evaluate the prefix expression step by step.

  1. Write the tokens in prefix order: * + 3 + 3 ↑ 3 + 3 3 3

  2. Evaluate the innermost addition: + 3 3 = 6.

  3. Evaluate the exponent using that result: ↑ 3 6 = 3^6 = 729.

  4. Evaluate the next addition: + 3 729 = 732.

  5. Evaluate the next addition: + 3 732 = 735.

  6. Multiply the two operands of the initial *: * 735 3 = 735 × 3 = 2205.

Final answer: 2205

Explore the full course: Coding For Placement