Advertisement
informaticage

Percentage C++ bribro

Dec 30th, 2020
1,125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. /// Returns the percentage % of n
  4. double percentage(double n, double percentage) {
  5.     return (n / 100) * percentage;
  6. }
  7.  
  8. int main () {
  9.     using namespace std;
  10.     int n;
  11.     cin >> n;
  12.  
  13.     cout << "Sconto sara' di: " << percentage(n, 20) << endl
  14.         << "Prezzo rimanente di: " << n - percentage(n, 20) << endl;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement