Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ program plz help! For the function part, if you enter 123, you should first 123/10 to get 12, 123%10 to get 3, 12/10 to
C++ program plz help! For the function part, if you enter 123, you should first 123/10 to get 12, 123%10 to get 3, 12/10 to get 1 and 12%10 to get 2 and then add 1 ,2, and 3 up to get 6.
Exercise 1 Write a function called SumDigits that takes in an INTEGER parameter and computes and returns the sum of its digits. If the incoming integer is negative, then disregard the negative (and still compute the sum of the digits, as a positive result). 1. This function should not depend on any LIMIT to the number of digits. Assume no limit to how many digits a number can have (remember the range of an int depends on the computer architecture-- it differs for different machines the function should work for any number of digits). o To test this function, write a main() routine that enters a loop, in which the user is prompted and allowed to enter any integer (0 to exit the loop), and the integer is sent to the function and the result printed. The user should keep being asked for inputs until they type a 0 to exit. 2. NOTE: You may not not use strings anywhere in this lab. So no converting the int to a stringStep 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