64 671
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #55036 in C++ for paul

Question #55036
write recursive functions to generate the following patterns of stars:
****
***
**
*
*
**
***
****
Expert's answer
Answer:
#include <iostream>

using namespace std;

void print_stars(int level)
{
for (int i = 0; i < level; ++i)
{
cout << '*';
}

cout << endl;
}

void print_stars_recursive(int level)
{
if (level < 1)
return;

print_stars(level);

print_stars_recursive(level - 1);

print_stars(level);
}

int main()
{
print_stars_recursive(4);

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions