Question: Write a function addMult (number, mod) that returns summation of all the digits of a given number when the mod is 1, and it returns

 Write a function addMult (number, mod) that returns summation of all

Write a function addMult (number, mod) that returns summation of all the digits of a given number when the mod is 1, and it returns the product of digits of the number when the mod is 2. The function returns -1 for any mod values other than 1 and 2. The following is the function prototype: int addMult(int number, int mod); Write the main() function to check if your function works properly. For this purpose, take a number and mode from the user and display the result. Note that the following is just an example, your program should work on varying length of numbers. Sample function calls: int result = addMult (1234, 1) result is 10. int result = addMult (1234, 2) result is 24. Sample Output Screens: Enter a number> 452 Make a selection> 1- Sum Digits 2- Multiply Digits Enter a number> 452 Make a selection> 1- Sum Digits 2- Multiply Digits >>> 2 Result of your selection is> 40 >>> 1 Result of your selection is> 11 Enter a number> 15123 Make a selection> 1- Sum Digits 2- Multiply Digits >>> 2 Result of your selection is> 30

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!