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");
}

Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: