draw a flowchart to input the cost price and the selling price of an article . if the selling price is more than the cost price then calculate and display actual profit and profit percent otherwise , calculate and display actual loss and loss percent . if the cost price and the selling price are equal , the programs displays the message neither profit nor loss.
Answers
Program in C++
#include<iostream>
using namespace std;
int main()
{
double CP, SP;
cout<<"Enter cost price : ";
cin>>CP;
cout<<"Enter selling price : ";
cin>>SP;
if(SP > CP)
{
double P = SP - CP;
double P_per = (P / CP) * 100;
cout<<"Profit = "<<P<<endl;
cout<<"Profit Percentage = "<<P_per<<"%";
}
else if(CP > SP)
{
double L = CP - SP;
double L_per = (L / CP) * 100;
cout<<"Loss = "<<L<<endl;
cout<<"Loss Percentage = "<<L_per<<"%";
}
else
{
cout<<"Neither loss nor profit";
}
return 0;
}
Output 1:
Enter cost price : 100
Enter selling price : 120
Profit = 20
Profit Percentage = 20%
Output 2:
Enter cost price : 100
Enter selling price : 75
Loss = 25
Loss Percentage = 25%
Output 3:
Enter cost price : 100
Enter selling price : 100
Neither loss nor profit