Write a program that uses recursion to determine ones age


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 & v)
void output(vector 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.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write a program that uses recursion to determine ones age
Reference No:- TGS01411278

Now Priced at $30 (50% Discount)

Recommended (96%)

Rated (4.8/5)