logo CodeStepByStep logo


Write a function named xkcdDatingRange that accepts three parameters: an integer for a person's age, and two integer references for a minimum and maximum, and that fills the min/max integers with the person's xkcd "dating range" as described in the following web comic strip:

Your minimum xkcd dating age is half your own age plus 7. Your maximum xkcd dating range is your own age, minus 7, then doubled. For example, the call of datingRange(48, min, max); sets min to 31 and max to 82. You may assume that the age value passed is a non-negative integer.

Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.