- Thursday, April 04, 2019. If you have problems, late work will be accepted before Friday with no penalties. Late work may be submitted on Saturday or Sunday with 5% penalty per day. No work will be accepted after Sunday.
- Files to be submitted: source code (*.cpp, *.cxx, *.h, see below for details). Please don't send your excutable files. Please submit your files to email@example.com, with the subject line "CSc212 Assignment 5".
void binary_print(ostream& outs, unsigned int n);The function prints the value of n as a BINARY number to the ostream outs. If n is zero, then a single zero is printed; otherwise no leading zeros are printed in the output. The '\n' character is NOT printed at the end of the output.
n=0 Output:0NOTE: Your recursive implementation must not use any local variables.
void triangle(ostream& outs, unsigned int m, unsigned int n)Hint: Only one of the arguments changes in the recursive call. Which one?
// Precondition: m <= n
// Postcondition: The function has printed a pattern of 2*(n-m+1) lines
// to the output stream outs. The first line contains m asterisks, the next
// line contains m+1 asterisks, and so on up to a line with n asterisks.
// Then the pattern is repeated backwards, going n back down to m.
/* Example output:
triangle(cout, 3, 5) will print this to cout:
double pow(double x, int n);
// Precondition: If x is zero, then n must be positive.
// Postcondition: The value returned is x raised to the power n.
Hint: use the formula x^2n = x^n x^n
4. Repeated and Indented Sentences (Project 1, page 450)
Write a function that produces output like the following:
This was written by calling number 1.
This was written by calling number 2.
This was written by calling number 3.
This was written by calling number 4.
This was ALSO written by calling number 4.
This was ALSO written by calling number 3.
This was ALSO written by calling number 2.
This was ALSO written by calling number 1.
In the above example, the recursion stopped when it reached four levels deep, but your function should be capable of continuing any specific level with the following function prototype.
void indented_sentences(size_t m, size_t
// precondition: m <=n;
//postcondition: print out the above pattern by calling number from m to n