How do you find the largest of 3 numbers in computer programming?

1 answer

Answer

1232980

2026-07-24 07:25

+ Follow

To find the largest of three numbers you must first find the largest of two numbers:

int max (int a, int b) { return a>b?a:b; // or, equivalently: if (a>b) return a; else return b;

}

Now we can use this function to find the maximum of three:

int max3 (int a, int b, int c) {

return max (max (a,b), c);

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.