Expert in study
alarm
Ask
Computer Science
Mikazuru

Find the sum of squares of individual digits of a number 'sqdnumber' and store the sum in variable 'sqdNumber_result'. E.g. if the number is 234, the sum is computed as (22 + 32 + 42 = 4 + 9 + 16 = 29)

answers: 1
Register to add an answer
The time for answering the question is over
52 cents James Hamilton
Answer:

The difficult part here is to extract the digits.

You can do this in a single loop.

Extract the digit in the units place by doing a mod 10 -> digit = number % 10.

To continue the loop reduce the number by dividing it by 10 -> number /= 10.

I'm sure you can figure out the rest by yourself.

But if you have trouble doing that, try outputting the values of each variable inside the loop.

112
James Hamilton
For answers need to register.
Contacts
mail@expertinstudy.com
Feedback
Expert in study
About us
For new users
For new experts
Terms and Conditions