Write a program that uses recursion

Write a program that uses recursion

1. Write a program that uses recursion to determine one’s age. The user will enter the current year and  the year they were born (birth year) from the keyboard. The program will output the current age of the user. Check positive and zero cases only. A recursive function must be used for full credit. No recursive helper functions may be used as well. Output should be user friendly. 

Name the program:

TestRecAgeXX.cpp, where XX are your initials.  

2. The two sets of output below show the results of successive circular rotations of a vector. One set of data is for a vector of integers, and the second is for a vector of strings.

1  3  5  7

3  5  7  1

5  7  1  3

7  1  3  5 

a  b  c  d  e

b  c  d  e  a

c  d  e  a  b

d  e  a  b  c

e  a  b  c  d

Write two template functions that can be used to rotate and output a vector of a generic type:

void rotateLeft(vector <T& v)

void output(vector <T v)

The first function performs a single circular left rotation on a vector, and the second prints out the

vector passed to it as a parameter. Write a test program that will test the two functions by generating

output similar to above. Use element types of

int,double,char and string. Must use templates and

function headers above for full credit. Use C++ string class. Output should look similar to the text.

Name the program:

TestRotateTemplateXX.cpp, where XX are your initials.
Powered by