C program to find Profit or Loss

In this tutorial you will learn about the C program to find Profit or Loss and its application with practical example.

C program to find Profit or Loss

In this tutorial, we will learn to create a C program that will find Profit or Loss in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Conditional Statements in c programming.

What is the Profit or Loss?

The profit means the extra amount received from the buyer for the product, rather than that of its actual price. If the product is sold at the price below the cost price, then it will be taken as a loss in that product.

Algorithm:-

Program to find Profit or Loss.

In this program, we will first take the cost price and the selling price from the user. After taking the input, we will find whether the cost price is equal, greater, or lesser than the selling price. Now we will use the required functions to calculate the profit/loss for the product. At last, we will print the output to the user using the printf(); function.

Below is an example of profit-loss calculation.

With the help of this program, we can find Profit or Loss.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

  • cp  = it will hold the input value of the cost price.
  • sp  = it will hold the input value of the cost price.

Taking the input cost price and the selling price from the user.

In this section of the code of the program, we will calculate the profit and the loss for the user.

Printing the roots of the given numbers by the user.

In this tutorial we have learn about the C program to find Profit or Loss and its application with practical example. I hope you will like this tutorial.