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.



C++ Program : Finding the Profit and Loss C++  Program :  Finding the Profit and Loss Reviewed by Awais Shah on 08:36:00 Rating: 5

No comments:

Powered by Blogger.