Find absolute value of any number

the absolute value (or modulus) |x|of a real number x is the non-negative value of xwithout regard to its sign.
If number is less than zero return -(number) otherwise return number
public class OwnAbsoluteFunction {
   
     static int getAbsolute(int i){
          return(i>0?i:-i);
     }
    
     public static void main(String[] args) {
          int i=-10;
        System.out.println(“i=”+getAbsolute(i));
     }
    
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

23 − 15 =