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);
    }
}

1 comment:

  1. I like your post very much. It is very much useful for my research. I hope you to share more info about this. Keep posting java online training hyderabad

    ReplyDelete

ShareThis