CS1023 Homework 3 Recursion February 17, 2012 1. Write an application that has 4
ID: 3638843 • Letter: C
Question
CS1023 Homework 3 Recursion
February 17, 2012
1. 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
Output from your program might be:
2. Trace by hand the execution of
(a) DigitalRoot(85384) (b) T(67,67)
To be handed in:
Submit your source code via Blackboard. Copy and paste the output from your application as comments at the end
A plain text file with your tracings for Question 2
Hard copies of your code and solution for Question 2 must be submitted by 5:00pm Note that the marker collects the assignments promptly at 5:00pm on Fridays. You will be charged your one free extension if you submit even a minute late.
Be sure to include your name and student number on all files submitted