logo CodeStepByStep logo

SumOfDigits

Language/Type: C# loops parameters return

Write a method named SumOfDigits that accepts an integer parameter and computes and returns the sum of all the digits of that number. For example, SumOfDigits(38015) returns 3+8+1+0+5 or 17. For negative numbers, return the same value as if the number were positive. For example, SumOfDigits(-72) returns 7+2 or 9.

Method: Write a C# method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.