Calculating Gain Percentage: Vikram buys an old scooter for Rs. A and spends Rs. B on its repairs. If he sells the scooter for Rs. C , what is his gain %?![[Solved] Calculating Gain Percentage with C++ [Solved] Calculating Gain Percentage with C++](https://app.e-box.co.in/uploads/Image/scooter.jpg)
Write a program to compute the gain %.
Input Format:
The first input is an integer which corresponds to A. The second input is an integer which corresponds to B. The third input is a float which corresponds to gain %.
Output Format:
Refer sample input and output for formatting specifications.
The float values are displayed correct to 2 decimal places.
Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]
Price of old scooter:
4700
Repair amount:
800
Selling price:
5800
Gain percentage is 5.45
Solution
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
cout<<"Price of old scooter:"<<endl;
cin>>a;
cout<<"Repair amount:"<<endl;
cin>>b;
cout<<"Selling price:"<<endl;
cin>>c;
printf("Gain percentage is %.2f",((c-a-b)*1.0/(a+b))*100);
return 0;
}Happy Learning – If you require any further information, feel free to contact me.
![[Solved] Calculating Gain Percentage with C++ [Solved] Calculating Gain Percentage with C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Calculating-Gain-Percentage-with-C.png)
![[Solved] Number Challenge with Java, C++, Python](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Number-Challenge-with-Java-C-Python-300x200.png)
![[Solved] Geeta prefers to buy specific items, a 10 percent discount is provided if she buy more than 1200 of them](https://realcoder.techss24.com/wp-content/uploads/2022/09/Solved-Geeta-prefers-to-buy-specific-items-a-10-percent-discount-is-provided-if-she-buy-more-than-1200-of-them-300x200.png)
![[Solved] To the Magic Show with Java, C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-To-the-Magic-Show-with-Java-C-300x200.png)