How can Print This shape using a recursive function and an iterative function
* & * &
* & *
* &
*
*
* &
* & *
* & * &
#include<iostream>
#include<string>
using namespace std;
void print(int x)
{
if(x>=1)
{
for(int i=1;i<x;i++)
{cout<<"*&* ";}
cout<<endl;
print(x-1);}
for(int i=1;i<x;i++)
cout<<"*& "<<endl;
};
void main()
{
print(4);
}
Last edited on