Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

More Books

Students also viewed these Databases questions

Question

What do firms become multinational?

Answered: 1 week ago

Question

What are the different types of application architectures?

Answered: 1 week ago