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.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,623
Latest member
AndersonLo
Back