program:
#include<stdio.h>
#include<string.h>
int main()
{
float sp,cp,profit,loss;
printf("Enter cost price\n");
scanf("%f",&cp);
printf("Enter selling price\n");
scanf("%f",&sp);
if(sp>cp)
{
profit=sp-cp;
printf("Profit is %f rupee",profit);
}
else
{
loss=cp-sp;
printf("Loss is %f rupee",loss);
}
return 0;
}
output: