Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To be done with C++ pleae. **C++** Question 2 a) Sum of digits: Write a recursive function that takes as parameter an integer N and

To be done with C++ pleae. **C++**

image text in transcribed

Question 2 a) Sum of digits: Write a recursive function that takes as parameter an integer N and returns the sum of its digits. In this function you will need to call the function modulo defined in Exercise 1 above. Example N- 524 The sum of digits is: 11 b) Write a recursive function that takes an integer n as parameter. If n is odd, the function should update the value of n by multiplying it by 3 and adding 1. If n is even, the function should update the value of n by dividing it by 2. The process is repeated until the value of n becomes equal to 1. Further, the function should print the updated values of n and return the number of steps. Example: n=10 Updated values of n are: 10 16 The number of steps is: 7

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_2

Step: 3

blur-text-image_3

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

Students also viewed these Databases questions

Question

a neglect of quality in relationship to international competitors;

Answered: 1 week ago