Functions in C

Sort by

recency

|

858 Discussions

|

  • + 0 comments

    C language is one of the most powerful and fundamental programming languages. t20 exchange login

  • + 0 comments
    int max_of_four(int a, int b, int c, int d)
    {
        int max = a;
        if(b > max)
            max = b;
        if (c > max)
            max = c;
        if (d > max)
            max = d;
        return max;
    }
    

    `

  • + 0 comments

    int max_of_four(int a, int b, int c, int d) { if ((a>b)&&(a>c)&&(a>d)) { return a; } else if ((b>a)&&(b>c)&&(b>d)) return b; else if ((c>a)&&(c>b)&&(c>d)) return c; else return d; }

  • + 0 comments

    Here is my version of solution using ternary operator

    int max_of_four(int a,int b,int c,int d) {

     int largest;
    
        largest= (a>=b && a>=c && a>=d)?a: (b>=c && b>=d)?b: (c>=d)?c:d;
    
        return largest;
    

    }

  • + 0 comments

    Here is HackerRank Functions in C problem solution