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;
}
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.
I can't understand what is namespace std
ReplyDelete