Sunday 15 June 2014

C++ program to calculate profit and loss



Here is a C++ program to calculate profit and loss


 SOURCE CODE OUTPUT
#include <iostream>
using namespace std;
int main()
{
    float profit,loss,cp,sp,losspercent,gainpercent;
    cout<<"Enter cost price ";
    cin>>cp;
    cout<<"Enter selling price ";
    cin>>sp;
    if(cp>sp)
    {
        loss=cp-sp;
        losspercent=loss*100/cp;
        cout<<"Total loss : "<<loss<<endl;
        cout<<"Loss percentage : "<<losspercent;
    }
    else
    {
        profit=sp-cp;
        gainpercent=profit*100/cp;
        cout<<"Total profit : "<<profit<<endl;
        cout<<"Gain percentage : "<<gainpercent;
    }
    return 0;
}

Any questions regarding to program please write in comments.

1 comment: