Tuesday, 24 December 2013

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.(c++ code)

#include<iostream>
using namespace std;
#include<conio.h>
int main()
{
  int cprice,sprice,loss,profit; 
 
  cout<<"Enter Cost Price : RS ";
  cin>>cprice;
  cout<<"Enter Selling Price of an item : RS ";
cin>>profit;
  if(cprice>sprice)
  {
    loss=cprice-sprice;
    cout<<"You have made LOSS. Your Loss is RS " << loss;
  }
  else if(sprice>cprice)
  {
    profit=sprice-cprice;
    cout<<"You have gain PROFIT. Your Profit is RS " << profit;
  }
  else if(sprice=cprice)
  {
    cout<<"You have neither Loss nor Profit";
  }
  getch();
  return 0;

  /*  Letuswithc:

       this page is designed to help you learn C or C++.
  Understandable C and C++ programming tutorials, compiler reviews, source code, tips and tricks. 
         */
}

No comments:

Post a Comment