Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions

Question

2. Are you varying your pitch (to avoid being monotonous)?

Answered: 1 week ago

Question

3. Are you varying your speaking rate and volume?

Answered: 1 week ago