int round(int n){
          int a = (n / 10) * 10;
          int b = a + 10;
          return (n - a > b - n)? b : a;
        }
      

      Cpp language logo
      Round the number to nearest ten

      Java Recipes

      round() calculates the remainder of a number divided by 10, and then adds 10 to that number to create the new round number.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.