I need to round of a number (the input is guaranteed to be an integer & is positive) to the next multiple of 5.
I tried this:
int round = ((grade
To round up the general form should be:
((n + denominator -1) / denominator )* denominator
so in your case:
int round = ((grades[j] + 4)/5) * 5;
The reason we deduct 1 from the denominator is to handle exact multiples of the rounding value for instance:
((70 + 4) / 5) * 5
would yield 70
70