Go to Top

Friday, 21 October 2011

To find absolute value of an integer

Question 63 : Write a program in Java to find the absolute value of an integer.

Java Program :

class absolute
{
    static void cal(int a)
    {
        int b=a>0?a:-a;
        System.out.print("The absolute value of '"+a+"' : "+b);
    }
}

2 comments:

ShareThis