cumulativeDiscount program
Answers
Explanation:
/ CPP Program to find the Discount Percentage
#include <bits/stdc++.h>
using namespace std;
// Function to find the Discount Percentage
float discountPercentage(float S, float M)
{
// Calculating discount
float discount = M - S;
// Calculating discount percentage
float disPercent = (discount / M) * 100;
return disPercent;
}
// Driver code
int main()
{
int M, S;
M = 120;
S = 100;
// Setting the precision to 2 decimals
cout << std::fixed << std::setprecision(2)
<< discountPercentage(S, M) << "%" << endl;
M = 1000;
S = 500;
// Setting the precision to 2 decimals
cout << std::fixed << std::setprecision(2)
<< discountPercentage(S, M) << "%" << endl;
return 0;
}