C Program to Enter Cost Price and Selling Price and Find Profit or Loss - IProgramX

Q. Accept the cost price and selling price from the keyboard. Find out if the seller has made a profit or loss and display how much profit or loss has been made



Program

#include<stdio.h>
int main()
{
float cost,price,m;
printf("enter cost of keyboard : ");
scanf("%f",&cost);
printf("\n enter selling price of keyboard : ");
scanf("%f",&price);
m=cost - price;
if(m>0)
{
printf("profit = %f",m);
}
else if(m<0)
{
m=(-1)*m;
printf("loss = %f",m);
}
else
{
printf("NO profit NO loss");
}
}

Output:

enter cost of keyboard : 453

 enter selling price of keyboard : 405
profit = 48.000000

Post a Comment

0 Comments