I'm trying to write a program that gives me the largest of three inputted integers. I've been trying to make different functions with arguments and comparisons and none of them seem to be consistently giving me the largest integer. Some of the things i've been trying are
if(a > b > c)
max = a;
if (b > a > c)
max = b;
if (c > a > b)
max = c;
and another one
max = a;
if (max < b)
max = b;
if (max < c)
max = c;
return max;
and another one
if (x > y > z)
return x;
else if (y > x > z)
return y;
else
return z;
I've tried all of these and whenever I put in any 3 integers, it usually always gives me the first or last entered integer back, not the largest one. If anybody can help, it would be a really big help. Thanks in advance.



LinkBack URL
About LinkBacks


