C program to find profit or loss
Write a C program to accept the selling price and cost price of an item from user and find out whether its profit or loss. Program to find product or loss.
/* Aim: Program to check whether seller has made a profit or not */
#include <stdio.h>
void main()
{
float cost,sell,t;
printf("\n Enter the cost price:- ");
scanf("%f",&cost);
printf("\n Enter the selling price:- ");
scanf("%f",&sell);
t=sell-cost;
if(t>0)
{
printf("\n The seller has made a profit of Rs.%f \n \n",t);
}
else if(t<0)
{
printf("\n The seller has made a loss of Rs.%f \n \n",-(t));
}
else
{
printf("\n The seller has neither made profit nor loss \n \n");
}
}
Output:
Enter the cost price:- 8000
Enter the selling price:- 16000
The seller has made a profit of Rs.8000.000000