โ Back to Functions
Question 403
Percentage Function
Percentage Function
Write a functiondouble percentage(int obtained, int total)that returns the percentageobtained * 100.0 / total. Call it withpercentage(45, 50)and print the result with exactly 2 decimal places: 90.00 Multiply by100.0(a double) so the division is not integer division.
Expected Output:
90.00
Topics:
Functions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.