Menu Close

Compute profit and loss of a product

In primary mathematics classes, you all have learned about profit and loss.  

If cost price is greater than selling price, then there is a loss otherwise profit

Can you kindly automate the same?

Input:
First Line : Integer representing the Cost price

Second Line: Integer representing Selling Price


Output:
If Cost Price > Selling Price Print a “Loss” along with the amount of loss.

If Cost Price < Selling Price Print as "Profit" along with the amount of profit.

If Cost Price = Selling Price Print “No Profit No Loss”
#include <stdio.h>
int main()
{int cp,sp,amt;
scanf("%d%d",&cp,&sp);
if(sp>cp)
{
    amt=sp-cp;
    printf("Profit:%d",amt);
}
else if(cp>sp)
{
    amt=cp-sp;
    printf("Loss:%d",amt);
}
else
{
    printf("No Profit No Loss");
}
	return 0;
}

INPUT_1:
15945
13785

OUTPUT:
Loss:2160


INPUT_2:
26832
28513

OUTPUT:
Profit:1681



Morae! Q