5/15/2016

C++ Program To Determine Whether The Seller Made Profit or Loss.

Problem :- Write A C++ Program To Determine Whether The Seller Made Profit or Loss. Also Determine How Much Profit or Loss He Made 

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.

Formula :-

Loss = Cost price (C.P.) – Selling Price (S.P.)

Profit =Selling Price (S.P.)-Cost price (C.P.)

Profit or Loss is always calculated on the cost price. Marked price: This is the price marked as the selling price on an article, also known as the listed price

Solution :-

#include<iostream>
using namespace std;
int main()
{
float sp,cp,l,p;
while(1)
{
cout<<"\n\nEnter The Selling Price \n";
cin>>sp;

cout<<"Enter The Cost Price \n";
cin>>cp;

if(cp>sp)
{
l=cp-sp;
cout<<"\n\nLoss Is = "<<l;
}
else if(cp<sp)
{
p=sp-cp;
cout<<"\nProfit Is = "<<p;
}
else 
{
cout<<"\nNo Profit No Loss\n"; 
}
}
return 0; 
}

Output:-

C++ Program To Determine Whether The Seller Made Profit or Loss.

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: