Tuesday 17 May 2011

C++ Program To Determine Whether The Seller Made Profit or Loss. Also Determine How Much Profit or Loss He Made


C++ Program To Determine Whether The Seller Made Profit or Loss. Also Determine How Much Profit or Loss He Made
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.
 Formula: Loss = Cost price (C.P.) – Selling Price (S.P.)
                Profit=Selling Price (S.P.)-Cost price (C.P.)
 Profit or Loss is always calculated on the cost price. Marked price: This is the price marked as the selling price on an article, also known as the listed price
 Here Is A Code And All Three Conditions
#include<iostream>
#include<conio.h>
void main()
{
 float sp,cp,l,p;
 clrscr();
 cout<<"Enter The Selling Price \n\n";
 cin>>sp;

 cout<<"Enter The Cost Price \n\n";
 cin>>cp;

 if(cp>sp)
 {
  l=cp-sp;
  cout<<"\n\nLoss Is = "<<l;
 }
 else if(cp<sp)
 {
  p=sp-cp;
  cout<<"\nProfit Is = "<<p;
 }
 else
 {
  cout<<"\nNo Profit No Loss\n";
 }
 return 0;
}
 Output:-
Enter The Selling Price
500.00
Enter The Cost Price
300.00
Profit: 200

No comments:

Post a Comment