If the cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred.

#include<stdio.h>
void main()
{
	float sp,cp,proft,loss;
	printf("Enter cost price=");
	scanf("%f",&cp);
	printf("\nEnter selling price=");
	scanf("%f",&sp);
	proft=sp-cp;
	loss=cp-sp;
	
	if(sp>cp)
    {
	printf("\n Profit=%f",proft);
	}
    
	else
    {
    printf("\n Loss=%f",loss);
    }
    
}

The output will be

Post a Comment (0)
Previous Post Next Post