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