Code:int num =5648;
How do i get 5+6+4+8 easily ?
How to get all the digits separately in different variables and then add them ?
By "easily" I mean without using special functions.
Code:int num =5648;
How do i get 5+6+4+8 easily ?
How to get all the digits separately in different variables and then add them ?
By "easily" I mean without using special functions.
Code:while (n) { sum += n%10; n /= 10; }
Thanks! Cboard is a great place to get homework done.
Duh!
That was your home work?
If you wanted to reverse a positive number? You are welcome!
I suggest you read the rules before doing that again, http://cboard.cprogramming.com/annou...t.php?f=4&a=39
yeah i know, project euler questions are very booooooooooooooooring!
I never asked anyone to do my complete homework.please do not ask people to do your entire homework for you
I just asked for a hint. What can I do if someone comes and writes the piece of code ?How to get all the digits separately in different variables and then add them ?
Anyway, sorry. (I don't want to argue any more)
No, but that's what you were hoping for "I always get my boring homework done by others"
Sorry
you are welcome abk. next time, just PM me. i will do your home work. $0.5 per line of code.
manav, you should write your code so then
Code:while (n) { sum += n%10; n /= 10; }
no, like this:
$3.0 please!Code:while (n) { d = n%10; sum += d; n /= 10; }
Code:while (n) { d = n%10; sum += d; n /= 10; }
dz wOrkz...!!
ajayd, u want complete code? PM me! $0.5 per line