the
absolute value (or modulus) |x|
of a real number x is the non-negative value of x
without 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));
}
}
No comments:
Post a Comment