How to find greatest of 3 numbers using function using return?

CODE




How to find greatest of 3 numbers using function using return?

//Write a program to find greatest of 3 numbers using function using return…..

int main()
{
    int a,b,c,max;
    printf("\n enter a,b,c:");
    scanf("%d%d%d",&a,&b,&c);
    int gr(int a,int b,int c);
    max=gr(a,b,c);
    printf("\n greatest value=%d",max);
}
int gr(a,b,c)
{
    if(a>b)
    {
        if(a>c)
            return a;
        else
            return c;
    }
    else
        if(b>c)
            return b;
        else
            return c;
}


Output:
enter a,b,c:
45
78
12

 greatest value=78

How to find greatest of 3 numbers using function using return? How to find greatest of 3 numbers using function using return? Reviewed by Unknown on December 31, 2018 Rating: 5

No comments:

If you have any doubt or query ,comment below:

Programming copyright © 2018-19. Powered by Blogger.