CJCoding With Joseph

Percentage Function

Write a function double percentage(int obtained, int total) that returns the percentage obtained * 100.0 / total. Call it with percentage(45, 50) and print the result with exactly 2 decimal places:

90.00

Multiply by 100.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.