How to Calculate Percentage of Two Numbers

Percentage of Two Numbers Calculator

Use this calculator to find out what percentage one number is of another.

Understanding Percentages

A percentage is a way of expressing a number as a fraction of 100. It's often denoted using the percent sign (%). For example, 50% means 50 out of 100, or 0.5 as a decimal.

How to Calculate the Percentage of Two Numbers

To find out what percentage one number (the 'part') is of another number (the 'whole'), you use a simple formula:

Percentage = (Part / Whole) × 100

In this formula:

  • Part (Numerator): This is the number you want to express as a percentage of the other number.
  • Whole (Denominator): This is the total or the reference number against which the 'part' is being compared.

Step-by-Step Calculation

  1. Identify the Part and the Whole: Determine which number is the 'part' and which is the 'whole'.
  2. Divide the Part by the Whole: Perform the division.
  3. Multiply by 100: Take the result from step 2 and multiply it by 100 to convert the decimal or fraction into a percentage.

Examples

Example 1: Simple Percentage

You scored 80 marks out of a total of 100 marks in an exam. What percentage did you score?

  • Part = 80
  • Whole = 100
  • Calculation: (80 / 100) × 100 = 0.8 × 100 = 80%
  • Result: You scored 80%.

Example 2: Real-World Scenario

A store has 250 items in stock. On a particular day, 45 items were sold. What percentage of items were sold?

  • Part = 45
  • Whole = 250
  • Calculation: (45 / 250) × 100 = 0.18 × 100 = 18%
  • Result: 18% of the items were sold.

Example 3: Finding a Percentage of a Larger Number

If you have 50 apples and 15 of them are red, what percentage of the apples are red?

  • Part = 15
  • Whole = 50
  • Calculation: (15 / 50) × 100 = 0.3 × 100 = 30%
  • Result: 30% of the apples are red.

Why is this useful?

Calculating percentages is fundamental in many aspects of life and business:

  • Academics: Grading exams, understanding performance.
  • Finance: Interest rates, discounts, profit margins, tax rates.
  • Statistics: Analyzing data, survey results.
  • Everyday Life: Sales discounts, tips, ingredient proportions.
.percentage-calculator-container { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 700px; margin: 20px auto; padding: 25px; border: 1px solid #e0e0e0; border-radius: 8px; background-color: #ffffff; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); } .percentage-calculator-container h2 { color: #333; text-align: center; margin-bottom: 25px; font-size: 1.8em; } .percentage-calculator-container p { color: #555; line-height: 1.6; margin-bottom: 15px; } .calculator-input-group { margin-bottom: 18px; display: flex; flex-direction: column; } .calculator-input-group label { margin-bottom: 8px; font-weight: bold; color: #444; font-size: 1.05em; } .calculator-input-group input[type="number"] { padding: 12px; border: 1px solid #ccc; border-radius: 5px; font-size: 1.1em; width: 100%; box-sizing: border-box; } .calculator-input-group input[type="number"]:focus { border-color: #007bff; outline: none; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); } .percentage-calculator-container button { display: block; width: 100%; padding: 14px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; font-size: 1.2em; font-weight: bold; cursor: pointer; transition: background-color 0.3s ease, transform 0.2s ease; margin-top: 25px; } .percentage-calculator-container button:hover { background-color: #0056b3; transform: translateY(-1px); } .percentage-calculator-container button:active { transform: translateY(0); } .calculator-result { margin-top: 30px; padding: 20px; border: 2px solid #28a745; border-radius: 8px; background-color: #e9f7ed; color: #155724; font-size: 1.4em; font-weight: bold; text-align: center; word-wrap: break-word; } .calculator-result strong { color: #0f3d1a; } .calculator-article { margin-top: 40px; padding-top: 30px; border-top: 1px solid #eee; } .calculator-article h3 { color: #333; margin-top: 25px; margin-bottom: 15px; font-size: 1.5em; } .calculator-article ul, .calculator-article ol { margin-left: 20px; margin-bottom: 15px; color: #555; } .calculator-article li { margin-bottom: 8px; } .calculator-article code { background-color: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', Courier, monospace; color: #c7254e; } function calculatePercentage() { var partNumberInput = document.getElementById("partNumber"); var wholeNumberInput = document.getElementById("wholeNumber"); var resultDiv = document.getElementById("percentageResult"); var part = parseFloat(partNumberInput.value); var whole = parseFloat(wholeNumberInput.value); if (isNaN(part) || isNaN(whole)) { resultDiv.innerHTML = "Please enter valid numbers for both fields."; resultDiv.style.borderColor = "#dc3545"; resultDiv.style.backgroundColor = "#f8d7da"; resultDiv.style.color = "#721c24"; return; } if (whole === 0) { resultDiv.innerHTML = "The 'Whole (Denominator)' cannot be zero."; resultDiv.style.borderColor = "#dc3545"; resultDiv.style.backgroundColor = "#f8d7da"; resultDiv.style.color = "#721c24"; return; } var percentage = (part / whole) * 100; resultDiv.innerHTML = "" + part + " is " + percentage.toFixed(2) + "% of " + whole + "."; resultDiv.style.borderColor = "#28a745"; resultDiv.style.backgroundColor = "#e9f7ed"; resultDiv.style.color = "#155724"; }

Leave a Comment