Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a recursive function that takes as a parameter a nonnegative integer an

ID: 3549636 • Letter: 1

Question

1. Write a recursive function that takes as a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer is 4, then the pattern generated is:

**** *** ** * * ** *** **** 2. Write a recursive function that takes as a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer is 4, then the pattern generated is:

* ** *** **** **** *** ** * 1. Write a recursive function that takes as a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer is 4, then the pattern generated is:

**** *** ** * * ** *** **** 2. Write a recursive function that takes as a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer is 4, then the pattern generated is:

* ** *** **** **** *** ** *

Explanation / Answer

Having problems getting to print last star * and then need to reverse pattern.



[
void printStars( int x);

int main(int argc, char *argv[])
{

int x=0;

cout << "Enter a number for the largest line to print: ";
cin >> x;

printStars (x-1);

cout << endl << "Program created by Student" << endl;
system("PAUSE");
return EXIT_SUCCESS;
} // emain()



void printStars( int x)
{

int i;

if (x == 0)
return;
for(i = 0; i <= x; i++)
cout << " * ";
cout << " ";


printStars (x-1);
}

] Write a recursive function that takes as a parameter a non-negative integer and generates the following pattern of stars. If the non-negative integer is 4, then the pattern generated is: