Write an application that has 4 functions: (a) int main() Controls the program a
ID: 3639042 • Letter: W
Question
Write an application that has 4 functions:(a) int main() Controls the program and makes calls to the other functions. Displays the results of the function calls.
(b) int GetData(string message) Displays the message passed in its parameters and returns an integer value that it acquires from the user.
(c) int DigitalRoot(int n) Calculates the digital root of an integer. The digital root of a number is defined by summing its digits repeatedly until only a single digit remains. For example:
563456 = 5 + 6 + 3 + 4 + 5 + 6 = 29 2 + 9 = 11 1+1=2
(d) int T(int m,int n) Calculates the value of T(m,n) where
T(m,n) = n if m <= 1 T(m,n) = m if n <= 1 T(m,n) = 2 * T(m/2,n/3) otherwise
Output from your program might be:
This program demonstrates recursion I will caclculate the digital root of the number you enter now: 1223 The digital root of 1223 is 8 Now I will calculate the value of T(m,n) Enter m 5 Enter n 8 The value of T(5,8) is 0
Explanation / Answer
int GetData(string message) { printf("%s ", message); int value=0; printf("enter value "); scanf("%d", value); return value; } int T(int m, int n) { if (mRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.