What would be the best way optimise the if statments, I feel other like there is a more short and sweet way to get it done | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What would be the best way optimise the if statments, I feel other like there is a more short and sweet way to get it done

https://code.sololearn.com/caTKh8ephz0S/?ref=app https://code.sololearn.com/ccsmPazQqRnN/?ref=app

9th Jan 2019, 8:26 AM
Cedar Bishop
Cedar Bishop - avatar
2 Answers
+ 2
In these cases the while or do while loop are pretty useful: static int DigitCombiner(int a, int b) { int c = b; do { a *= 10; } while((c /= 10) > 0); int sum = a + b; return sum; }
9th Jan 2019, 10:14 AM
Sekiro
Sekiro - avatar
0
Thanks, thats a very creative solution
9th Jan 2019, 11:41 AM
Cedar Bishop
Cedar Bishop - avatar