If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made the profit or incurred loss. Write a C program to determine how much profit or loss incurred in percentage.
Program Code:
#include<stdio.h>
void main()
{
float cp,sp,p,l,pp,lp;
printf("Enter the costprice and selling prices of an article: ");
scanf("%d%d",&cp,&sp);
if(cp > sp)
{
l=cp-sp;
lp=(l/cp)*100;
printf("The seller had a loss and loss precentage=%f",lp);
}
else if(sp > cp)
{
p=sp-cp;
pp=(p/cp)*100;
printf("The seller had a profit and profit percentage=%f",pp);
}
else
printf("The seller had no profit no loss");
}
Post A Comment:
0 comments: