Go to Top

Tuesday, 9 August 2011

To find the absolute value of a given integer

Question 39 : Write a program in Java to find the absolute value of an integer given by the user.


Java Program : 


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

No comments:

Post a Comment

ShareThis