You call
15 / sum-of-values
a "percentage".
Is that the percentage that you are looking for?
Each element could be 0. Their sum would be 0. How much is
15 / 0
?
the percentage of each of these numbers in the matrix |
Sounds like:
* How many elements have value 0?
* How many elements have value 1?
...
* How many elements have value 9?
Back to the "all 0" example: 15 out of 15 elements would be 0.
100% of the elements would have value 0.
Values 1-9 would occur in 0% of the elements.
Each of the values 0-9 would have its own percentage.
If you think that my interpretation is correct, then think what to do to your math.
What if I type
42
as the user? Should you validate the input?
PS.
* You have a typo in your code tag.
* Where do you use the <math.h>? Nowhere.
* If you would need math header, then do include <cmath>