Question

Write a program to check if a seller has made profit or loss.

Solution to Calculate Profit or Loss in C

Declare four variables for cost price, selling price, profit and loss. Accept cost price & selling price from user using printf() and scanf(). Use if block to check if SP is greater than CP. If selling price is more, then store the difference between selling price and cost price in profit variable and print the profit, else store the difference between cost price and selling price in loss variable & print the loss.

Output

Download the solution:

Let us know if you are stuck somewhere and need help. You are also free to request some other problem using our comments section or contact form and we will try our best to provide you a solution to your problem. Alternatively, you can also contact us on our social media pages.