C Program to find Profit or Loss
#include<stdio.h>
int main()
{
float cp, sp, amount; /* cp = cost price & sp = selling cost*/
printf("Enter cost price: ");
scanf("%f",&cp);
printf("Enter selling price: ");
scanf("%f",&sp);
if(sp > cp)
{
amount = sp - cp;
printf("Profit = %.2f",amount);
}
else if(cp > sp)
{
printf("Loss = %.2f",amount);
}
else
{
printf("No profit no Lost");
}
}
Output
Enter cost price: 100
Enter selling price: 135
Profit = 35.00