If I was to read in 7 integers and I wanted to find the largest number using only if statements (no arrays) but also keep the amount of code to a reasonable amount, does anyone know how to do that?
Not saying this is the best way, just the method that comes to mind.
int Best = Value1;
if (Value2 > Best) Best = Value2;
if (Value3 > Best) Best = Value3;
if (Value4 > Best) Best = Value4;
if (Value5 > Best) Best = Value5;
if (Value6 > Best) Best = Value6;
if (Value7 > Best) Best = Value7;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.