another programming question

mooo

thecyberninja
Joined
6 Jan 2004
Messages
886
was thinking about just putting this in other post but wasn't sure.

Say i input 4 numbers (we will use 3456), is there a way to just add the numbers like 3+4+5+6=x .. i was thinking a while loop but i am not sure how to make it read one place when you have to input the whole number at once. Does anyone know a formula that might do this? thanks in advance.

mooo


(mod if you thinkit should be moved pls do, was not sure if i should or not)
 
nm, figured it out i think

if (n==0) {return 0)
else
return (n%10) + calcular(n/10);
 

Members online

No members online now.

Forum statistics

Threads
62,021
Messages
673,242
Members
5,642
Latest member
osipov
Back
Top