# Program to find the Discount Percentage in C++

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

In this problem, we are given two numbers that define the marked price(M) and selling price(S) of a certain product. Our task is to create a program to find the Discount Percentage in C++.

Discount is the amount that is deducted from the actual price (marked price) on a product.

The formula for discount is,

discount = marked price - selling price

Discount percentage is the percentage of the price that is deducted from the actual price of the product.

The formula for discount percentage is,

discount percentage = (discount / marked price ) * 100

Let’s take an example to understand the problem,

## Input

240, 180

## Output

25%

## Explanation

Discount = (240 - 180) = 60
Discount percentage = (60/240)*100 = 25%

## Solution Approach

The formulas for discount and discount percentage are −

Discount = marked price - selling price
Discount percentage = (discount / marked price ) * 100

Program to illustrate the working of our solution,

## Example

Live Demo

#include <iostream>
using namespace std;
int main() {
float MP = 130, SP = 120;
float DP = (float)(((MP - SP) * 100) / MP);
printf("The discount percentage on the given product is %.2f\n", DP);
return 0;
}

## Output

The discount percentage on the given product is 7.69