Bird
Raised Fist0

Which of the following is the correct way to represent a discount of 20% in a pricing system?

easy🧠 Conceptual Q12 of Q15
LLD - Design — Online Shopping Cart
Which of the following is the correct way to represent a discount of 20% in a pricing system?
Adiscount = 20
Bdiscount = 2
Cdiscount = 0.2
Ddiscount = 200
Step-by-Step Solution
Solution:
  1. Step 1: Understand percentage representation in code

    Percentages are usually represented as decimals for calculations, so 20% is 0.2.
  2. Step 2: Check each option

    discount = 0.2 uses 0.2 which is correct; others are incorrect as they represent wrong values.
  3. Final Answer:

    discount = 0.2 -> Option C
  4. Quick Check:

    20% = 0.2 decimal [OK]
Quick Trick: Use decimal for percentage (20% = 0.2) [OK]
Common Mistakes:
MISTAKES
  • Using whole number 20 instead of decimal
  • Confusing 2 or 200 as percentage
  • Not converting percentage to decimal

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes