C++ Program : Finding the Profit and Loss

Program :

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;
int main()
{
      double cp,sp,profit,loss,total;
      cout << "Enter the Cost Price of Item : " << endl;
      cin >> cp;
      cout << "Enter the Sale Price of Item : " << endl;
      cin >> sp;
      profit = sp-cp;
      loss= cp-sp;
      if (sp > cp )
      {
            cout << "You have profit of  :" << profit << "  Rs "<<  endl;

      }
      else if (cp > sp)
      {    
            cout << "WARNING !!!! You have a Loss of : " << loss << " Rs "<< endl;
      }
      else if (cp==sp)
      {
            cout << " WARNING !!! You have no Profit or Loss " << endl;
     
      }

return 0;
}

Output :

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.



Share on Google Plus

About Awais Shah

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment