C Program to Calculate Profit or Loss

C Program to Calculate Profit or Loss

How can we get the Profit or Loss amount in C language? We can get the Profit or Loss amount by subtracting Sell price from Actual price.

Profit or Loss calculation using C language :



#include
 
int main()
{
  float cp,sp,result;

  printf("Enter cost price : \n");
  scanf("%f",&cp);

  printf("Enter selling price : \n");
  scanf("%f",&sp);

  result = sp - cp;

  if(result > 0)
  {
  	printf("Profit : %f\n",result);
  }
  else
  {
  	printf("Loss : %f\n",result);
  }
 
  return 0;
}
    

Output :