Hey all,
I have an assignment for my beginning C++ class where my teacher wants us to use recursion to display ten stars ( ********** ) n times vertically. such that if n = 4 it would look like:
**********
**********
**********
**********
now normally I would use a void function that just does:
Code:
void rectangle(int n){
if (n >= 1) cout << "**********";
rectangle (n-1);
}
but my teacher would like us to cout the return of ten stars. How is that supposed to look?
I tried:
Code:
#include <iostream>
using namespace std;
string rectangle(int n){
if (n >= 1) return "**********";
rectangle(n-1);
}
int main(){
int n;
cout << "Please enter an n value: ";
cin >> n;
cout << rectangle(n);
return 0;
}
but it doesnt seem to be working.
Thanks for any and all help.