21. Write a C program to calculate profit or loss.
Solution :-
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int amt,sp,cp;
printf("Enter the Selling price :-");
scanf("%d",&sp);
printf("Enter the Cost price :-");
scanf("%d",&cp);
if(sp>cp)
{
amt = sp-cp;
printf("The Profit is :- %d",amt);
}
else if(cp>sp)
{
amt = cp-sp;
printf(":The Loss is :- %d",amt);
}
else
{
printf("No Pofit or No Loss");
}
getch();
}
Output :-