ProAnswers.org

c program to find the maximum of three numbers ?

c program to find the maximum of three numbers.
i want function.

1 Like

Try this…

int findMax(int x, int y, int z)
{
int max = x;

if(max < y)
max = y;

if(max < z)
max = z;

return max;
}

#include

main()

{

int a,b,c;

printf("

Input the three numbers :");

scanf("%d%d%d",&amp;a,&amp;b,&amp;c);

if(a&gt;b)

{

if(a&gt;c)

{

printf("

Maximum= %d
",a);

}

else

{

printf("Maximum= %d

",c);

}

}

else if(b&gt;c)

printf("

Maximum= %d
",b);

else

printf("

Maximum= %d
",c);

}