Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)
C Program To Calculate Profit or Loss In 2 Ways | C Programs
Latest :

C Program To Calculate Profit or Loss In 2 Ways | C Programs

C Program to calculate Profit or Loss – In this article, we will brief in on the way to calculate the profit or the loss on a given commodity or service.

Only the standard method will be used to calculate the same.

Suitable examples and sample programs have also been added so that you can understand the whole thing very clearly. The compiler has also been added with which you can execute it yourself.

As it is imminent, there are two prices associated with any particular commodity or service.

Those are as follows:

  • Cost Price
  • Selling Price

The Cost Price is the price at which the seller has bought something by themselves or the manufacturer’s overall expenditure behind making the same.

The Selling Price is the price at which someone sells the product or service to someone else.

C Program To Calculate Profit or Loss

As it is evident from the photo above, Profit is attained when the Selling Price is greater than the Cost Price. In this case, the seller will be able to accumulate some extra money from the buyer.

Similarly, Loss is incurred when the Selling Price is less than the Cost Price. In this situation, the seller has to shell extra amount to sell the product or service to the buyer.

So,

Profit = Selling Price – Cost Price

Loss = Cost Price – Selling Price

Both the values are positive.

Using Standard Method

1)Read the cost price and selling price.

2)Compare the cost price with selling price using if condition.

If selling price>= cost price then profit= selling price-cost price.

otherwise, loss= cost price – selling price.

Output:
Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)
x

Check Also

C Program To Print Number Of Days In A Month | Java Tutoring

C program to input the month number and print the number of days in that ...