Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using a while loop and if-else statements if required, write a function file that will add (sum) the DIGITS of any number entered. Your function
Using a while loop and if-else statements if required, write a function file that will add (sum) the DIGITS of any number entered. Your function should get the number (scalar) as an input 2. argument and return the sum as an output argument. You may use any of the following built-in functions to assist you: ceil, floor, round, fix, rem, or mod. HINT: What number do you need to divide by to get a single digit out of a long number? How do you keep track of what is left after the division? Here is an example of what the input and output should look like: Input number: 123456789 Output: 45 Test your code using: 98765 and 100001
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started