You are given a number, and you need to round it up or down to nearest multiple of 10, means round up or down to a number having 0 as last digit like as given below:
Input: 546
// After rounding down
Output: 540
// After rounding up
Output: 550
Rounding Down Number to Nearest Multiple of 10
You can do this by using Truncate() method of Math class in C#. Divide the number by 10, it moves the decimal point by 1 digit to left side in number. Then use Truncate() method, it will remove decimal part of number then multiply the returned number by 10. Finally you get the number rounded down to nearest multiple of 10.
Below C# sample code illustrates this scenario.
int num = 546;
int roundedDown = (Math.Truncate(num/10))*10;
Rounding Up Number to Nearest Multiple of 10
In this case, you need to follow the above approach and get the rounded down number to nearest multiple of 10 and then add 10 to the number.
Below C# sample code illustrates this scenario.
int num = 546;
int roundedUp = (Math.Truncate(num/10))*10 + 10;