Python Write a recursive function starsn that takes an input
Python: Write a recursive function stars(n) that takes an input a nonnegative integer and generates the pattern of stars shown below
>>> stars (4)
****
 ***
 **
 *
 *
 **
 ***
 ****
>>>
Solution
#include <iostream>
using namespace std;
void printStars( int n, char s);
int main()
{int n;
char s;
cout<<\"Please Enter The Number of Lines:\"<<endl;
cin>>n;
printStars(n,\'*\');
return 0;
}
void printStars(int n, char s){
int i;
for (i=0; i<n; i++){
cout<<s;
}
cout<<endl;
if(i<=n){
printStars(n-1,s);
}
for(i; i>0; i--){
cout<<s;
if(i<=0){
printStars(n+1,s);
}
}
cout<<endl;
}


