Given the Cost Price(CP) and Selling Price(SP) of a product. The task is to Calculate the Profit or Loss.
Input: CP = 1500, SP = 2000 Output: 500 Profit Input: CP = 3125, SP = 1125 Output: 2000 Loss
Profit = (Selling Price - Cost Price) Loss = (Cost Price - Selling Price)
Below is the required implementation:
Time Complexity: O(1)
Auxiliary Space: O(1)
Please refer complete article on Program to calculate Profit Or Loss for more details!