- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# 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 Questions & Answers
- Find cost price from given selling price and profit or loss percentage in C++
- Program to find maximum profit we can make by holding and selling profit in Python
- Differentiate between price, value and cost
- Maximum profit after buying and selling the stocks in C++
- Program to find maximum profit we can make by buying and selling stocks in Python?
- Program to find maximum profit after cutting rods and selling same length rods in Python
- Maximum profit by buying and selling a share at most twice
- Program to find maximum profit by selling diminishing-valued colored balls in Python
- Program to find maximum profit after buying and selling stocks at most two times in python
- C++ Program to find out the maximum amount of profit that can be achieved from selling wheat
- Find percentage from marks in MySQL
- Program to find maximum profit we can get by buying and selling stocks with a fee in Python?
- Maximize the profit by selling at-most M products in C++
- Compare bid price and offer price
- C++ Program to find winner and final price in a second price auction event

Advertisements