Computer Science, asked by hirafiaz1997, 2 months ago

Write the algorithm and flowchart to accept the cost price and selling price of any item then print the profit and profit percentage?

Answers

Answered by dreamrob
15

Algorithm:

  1. Start
  2. Input CP, SP
  3. If (SP > CP) then
  4. P = SP - CP
  5. P_per = (P / CP) * 100
  6. Print P and P_per
  7. Else if (CP > SP) then
  8. L = CP - SP
  9. L_per = (L / CP) * 100
  10. Print L and L_per
  11. Else
  12. Print "No profit, no loss"
  13. End if
  14. Stop

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.0;

 cout<<"Profit = "<<P<<endl;

 cout<<"Profit percentage = "<<P_per<<"%";

}

else if(CP > SP)

{

 double L = CP - SP;

 double L_per = (L / CP) * 100.0;

 cout<<"Loss = "<<L<<endl;

 cout<<"Loss percentage = "<<L_per<<"%";

}

else

{

 cout<<"No profit, no loss";

}

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 : 80

Loss = 20

Loss percentage = 20%

Output 3:

Enter cost price : 100

Enter selling price : 100

No profit, no loss

Attachments:
Answered by anuradhapandey1945
1

Explanation:

This is your prefect answer .

hope it is thankful

Attachments:
Similar questions