+ 4

Code challenge question

here is a code challenge question for all coders in Sololearn. write a function that takes integer input and return the sum of all digits of the number. public int digit_sum(int num) { //this is for you to fill } digit_sum(1042) must return 7.

18th Jul 2017, 7:07 PM
Millo
Millo - avatar
11 Answers
18th Jul 2017, 8:34 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 8
https://code.sololearn.com/WvjnyPF3L8iY/?ref=app As basic as I could make it.
18th Jul 2017, 7:31 PM
The Coding Sloth
The Coding Sloth - avatar
18th Jul 2017, 10:39 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
18th Jul 2017, 7:53 PM
Kevin Eldurson
Kevin Eldurson - avatar
18th Jul 2017, 8:04 PM
Kevin Eldurson
Kevin Eldurson - avatar
+ 5
18th Jul 2017, 7:38 PM
Kevin Eldurson
Kevin Eldurson - avatar
21st Jul 2017, 6:31 PM
Garikai
Garikai - avatar
+ 4
Oh, I just saw this was a general question, not C++ specific, anyway at least I got a bit more familiar with C++ type conversion, brb with a C# version.
18th Jul 2017, 7:40 PM
Kevin Eldurson
Kevin Eldurson - avatar
+ 3
yes it is open for any language
18th Jul 2017, 7:44 PM
Millo
Millo - avatar
+ 2
all are awesome!
21st Jul 2017, 7:37 PM
Millo
Millo - avatar