• + 5 comments

    A common thing to do is look to see if an abs function exists. However abs is such a trivial procedure you can either make a fuction/macro/conditionals to solve it ex:

    #define abs(x) ((x) < 0 ? -(x) : (x))
    

    or

    int abs(int x)
    {
        if(x < 0) {
            return -x;
        } else {
            return x;
        }
    }