Bird
0
0

Given the code below, what is the final value of total?

hard📝 Application Q8 of 15
C - Operators and Expressions
Given the code below, what is the final value of total?
int total = 50;
int discount = 10;
total -= discount * 2;
total += 5;
A35
B25
C45
D55
Step-by-Step Solution
Solution:
  1. Step 1: Calculate discount * 2

    discount * 2 = 10 * 2 = 20.
  2. Step 2: Apply 'total -= 20'

    total = 50 - 20 = 30.
  3. Step 3: Apply 'total += 5'

    total = 30 + 5 = 35.
  4. Final Answer:

    Final value of total is 35 -> Option A
  5. Quick Check:

    Apply operators stepwise for correct total [OK]
Quick Trick: Calculate expressions before assignment operators [OK]
Common Mistakes:
  • Adding before subtracting
  • Ignoring operator precedence
  • Miscomputing discount * 2

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes