I need to to write a method that is called like printTriangle(5);
. We need to create an iterative method and a recursive method (without ANY iteration). The out
void trianglePrint(int rows){
int static currentRow = 1;
int static currentStar = 1;
// enter new line in this condition
// (star > currentrow)
if (currentStar > currentRow ){
currentStar = 1;
currentRow++;
cout << endl;
}
if (currentRow > rows){
return; // finish
}
cout << "*";
currentStar++;
trianglePrint(rows);
}