Write a C++ program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred. Cost price and selling price of an item is input by the user.

Program Code:
#include<iostream>
using namespace std;
int main()
{
int cost_price;
int selling_price;
int result;
cout<<"Enter cost price of item : ";
cin>>cost_price;
cout<<endl;
cout<<"Enter selling price of item : ";
cin>>selling_price;
cout<<endl;
result=selling_price - cost_price;
if(result > 0)
{
cout<<"Profit incurred : "<<result;
}
else
{
if(result < 0)
{
 cout<<"Loss incurred : "<<-(result);
}
else
{
cout<<"No profit incurred / No loss incurred ";
}
}
return 0;
}

The program output is tested on www.jdoodle.com
Output:
Enter cost price of item : 1000
Enter selling price of item : 1201
Profit incurred : 201


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: