Profit and Loss using if else

If 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>
main()
{

int cp,sp,profitloss;

printf ("Enter the cost price and selling price of the item: ");

scanf ("%d %d", &cp, &sp);

profitloss=sp-cp;

if (sp>cp)
{
printf("Profit=%d",profitloss);

}
else if (cp>sp)
{
printf ("Loss=%d",profitloss);

}
else if(sp==cp)
{

printf ("No profit no loss");
}
}


The file can be downloaded at:
Download File

Comments

Popular posts from this blog

C Program - Calculation of Area and Circumference of a Circle using Pointers

Matchstick Game using C Programming

C Program to Calculate Factorial of a number using Recursion