Check out example codes for "c++ round to nearest multiple of". It will help you in understanding the concepts better.

Code Example 1

// CPP program to round the given  
// integer to a whole number  
// which ends with zero. 
#include <bits/stdc++.h> 
using namespace std; 
  
// function to round the number 
int round(int n) 
{ 
    // Smaller multiple 
    int a = (n / 10) * 10; 
      
    // Larger multiple 
    int b = a + 10; 
  
    // Return of closest of two 
    return (n - a > b - n)? b : a; 
} 
  
// driver function 
int main() 
{ 
    int n = 4722; 
    cout << round(n) << endl; 
    return 0; 
}

Learn ReactJs, React Native from akashmittal.com