Subscribe Us

C program to calculate profit / loss - c exercise - smartduniya

We all know about profit and loss . It is a simple mathamatics. A Shopkeeper buy a product from company and sell us .

Cost price is total ammount of money by which the shopkeeper buy product from company.
Sell price is the total amount of money , which price sell the product to us .
We all know about profit and loss . if sell price is grater than cost price , made profit
. simple formula for profit is
profit = sell price - cost price
ex. A product cost price is Rs. 100 and sell price is Rs. 120. Calculate profit ?
Ans:
profit = s.p - c.p { s.p = sell price , c.p = cost price}

profit = 120 - 100 = 20
profit is Rs. 20 .

By the same way, if sell price is less than cost price , made loss .
simple formula for loss is
loss = cost price - sell price.
ex. A product cost price is Rs. 120 and sell price is Rs. 100. Calculate loss ?
Ans: loss = c.p - s.p { s.p = sell price , c.p = cost price}
loss = 120 - 100 = 20
loss is Rs. 20 .


If the cost price and sell price of an item are input through the keyboard ,
write a program to determine wheather the seller has made profit or incurred loss .
Also determine how much profit he made or loss he incurred



C program to Calculate profit and loss


Let's Go to the code :


Note :Click on the button to copy the text from the text field. Try to paste the text (e.g. ctrl+v) afterwards in a different window, to see the effect.


write the above code or copy this code . save this with '.c ' extension and run.In this screen User have to input cost price and sell price . Then press Enter to show profit / loss.

Calculate Profit


ex. A product cost price is Rs. 100 and sell price is Rs. 120. Calculate profit / loss ?
=> Run the code and put cost price and sell price , press enter.


OutPut :


Calculate Loss


ex. A product cost price is Rs. 120 and sell price is Rs. 100. Calculate profit / loss ?
=> Run the code and put cost price and sell price , press enter.


OutPut :

Hope you understand if you face any problem comment below ,will try to help you.

 

Don’t forget to Subscribe our Blog to get update. Just put your email on subscribe box and hit subscribe button , next verify your email , it will be done.

You will get every single post when we will upload in Smartduniya.


Also learn this post :


How to write comment in C ?

How to write keyword, identifires in C ?

How to write Printf() function in C ?

Post a Comment

0 Comments