using function + if condition

 #include <stdio.h>

#include <stdlib.h>


//return on function


int result;

int max(int num1, int num2, int num3)

{

     if(num1>= num2 && num1>=num3){

       result = num1;

     }

     else if(num2>= num1 && num2>=num3){

       result = num2;

     }


    else {


        result = num3;

    }



    return result;

}


int main()

{

    printf("max is %d\n", max(9,9,8));

    return 0;

}


Comments

Popular posts from this blog

Using Struct C

arrays in c programming

for loop with index in C