C Program to Calculate Profit or Loss

How to write a C Program to Calculate Profit or Loss. If the actual amount is less than the Sales amount then the product is in profits, else if the actual amount is greater than the Sale amount product is in Loss otherwise, no profit no loss

C Program to Calculate Profit or Loss Example

This C program to calculate profit or loos helps the user to enter the actual amount and Sales Amount. Using those two values, this C Program will check whether the product is in profit or Loss using Else If.

/* C Program to Calculate Profit or Loss */
 
#include<stdio.h>
 
int main()
{
  	float Unit_Price, Sales_Amount, Amount;
 
  	printf("\n Please Enter the Actrual Product Cost : ");
  	scanf("%f", &Unit_Price);
  
  	printf("\n Please Enter the Sale Price (or Selling Price) :  ");
  	scanf("%f", &Sales_Amount);
  
  	if (Sales_Amount > Unit_Price)
  	{
  		Amount = Sales_Amount - Unit_Price;
  		printf("\n Profit Amount  =  %.4f", Amount);
  	}
  	else if(Unit_Price > Sales_Amount)
    {
    	Amount = Unit_Price - Sales_Amount;
  		printf("\n Loss Amount  =  %.4f", Amount);
	}
  	else
    	printf("\n No Profit No Loss!");
 
  return 0;
}
C Program to Calculate Profit or Loss 1

Let me try another value

 Please Enter the Actrual Product Cost : 1225.25

 Please Enter the Sale Price (or Selling Price) :  1175.69

 Loss Amount  =  49.5601

another one

 Please Enter the Actrual Product Cost : 1400

 Please Enter the Sale Price (or Selling Price) :  1400

 No Profit No Loss!