- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures

- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces

# Find Selling Price from given Profit Percentage and Cost in C++

Consider we have the selling price, and percentage of profit or loss is given. We have to find the cost price of the product. The formula is like below −

$$Cost Price=\frac{Sell Price∗100}{100+percentage profit}$$ $$Cost Price=\frac{Sell Price∗100}{100+percentage loss}$$

## Example

#include<iostream> using namespace std; float priceWhenProfit(int sellPrice, int profit) { return (sellPrice * 100.0) / (100 + profit); } float priceWhenLoss(int sellPrice, int loss) { return (sellPrice * 100.0) / (100 - loss); } int main() { int SP, profit, loss; SP = 1020; profit = 20; cout << "Cost Price When Profit: " << priceWhenProfit(SP, profit) << endl; SP = 900; loss = 10; cout << "Cost Price When loss: " << priceWhenLoss(SP, loss) << endl; }

## Output

Cost Price When Profit: 850 Cost Price When loss: 1000

- Related Articles
- Find cost price from given selling price and profit or loss percentage in C++
- If cost price = Rs 400 and selling price = Rs 500, profit% =
- If Selling price $=$ S.P, Discount % $=$ D, find cost price.
- If the selling price of a bike is â‚¹19000 and the profit gained is 7% find the cost price.
- If cost price = Rs 600 and loss = 60, then selling price =
- If the cost price is 1,00,000 rupees and the selling price is 1,00,000 rupees, then is it a profit or loss?
- Cost of an item is rs 50. It was sold with a profit of 12 %. Find the selling price
- If Marked Price = 400â‚¹ and Selling Price =300â‚¹ , then what is the discount percentage ?
- A man sold a bicycle at 5% profit. If the cost had been 30% less and the selling price â‚¹63 less, he would have made a profit of 30%. What was the cost price of the bicycle ?
- By selling 100 oranges, a vendor gains a profit equal to the selling price of 20 oranges. Find his gain percent
- The price of the storybook increased from $20 \ to \ $30 of its cost. Find the percentage rise in the price of the storybook.
- Selling price of an article is â‚¹5600, loss incurred is $6 \frac{2}{3}$%. Find the cost price.
- If the selling price of 10 article is equal to cost price of 11 article, find the gain percent
- Program to find maximum profit we can make by holding and selling profit in Python
- The selling price of 12 pens is equal to the cost price of 15 pens. Find the gain per cent.

Advertisements