Write a function with this prototype:

#include < string >
void numbers(ostream& outs, const string& prefix, unsigned int levels);

The function prints output to the ostream outs. The output consists of the string prefix followed by "section numbers" of the form 1.1., 1.2., 1.3., and so on. The levels argument determines how may levels the section numbers have. For example, if levels is 2, then the section numbers have the form x.y. If levels is 3, then section numbers have the form x.y.z. The digits permitted in each level are always '1' through '9'. As an example, if prefix is the string "THERBLIG" and levels is 2, then the function would start by printing:

THERBLIG1.1.
THERBLIG1.2.
THERBLIG1.3.

and end by printing:

THERBLIG9.7.
THERBLIG9.8.
THERBLIG9.9.

The stopping case occurs when levels reaches zero (in which case the prefix is printed once by itself followed by nothing else).

The string class from < string > has many manipulation functions, but you'll need only the ability to make a new string which consists of prefix followed by another character (such as '1') and a period ('.'). If s is the string that you want to create and c is the digit character (such as '1'), then the following statement will correctly forms:

s = (prefix + c) + '.';

This new string s can be passed as a parameter to recursive calls of the function.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.