creating a christmas tree in C++

The program is created using the control statement

The program can be easily understood, so the variable name in the program is given according to their task. The user will depend on input value minimum 5 and maximum value output screen, which will show a complete tree.

Here is the program,

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
 
void main()
{
   clrscr();  
   int num,count=0;
    int center=30; // print tree into center of screen
  cout<<"Enter Number(Minimum 4 and Max 7): "; cin>>num;
   clrscr();
   cout<<"nn"; count=num-2;int joint=0; while(count>0) // count pyramid of tree
  {
     for(int row=0;row<num-count+1;row++) { for(int blank=num-joint+center;blank>=row; blank--)
       {
           cout<<" "; // print whole left side space
        }
       for(int left =0;left<=row+joint;left++)
       {
          cout<<"*"; // print left side part of tree
        }
      for(int right =0;right<=row+joint;right++)
      {
         cout<<"*";  // print right side part of tree
       }
     cout<<endl;
   }
count--; // decrement in number of pyramid
 joint++; // increase size of pyramid by one row
}
 //print bottom of tree
int v;
 for(int stem = 0;stem<2;stem++)
 {
   if(num==4)
       v=1;
   else
       v=0;
  cout<<setw(v+center+num+num-num/2);
  cout<<"| |"<<endl;
 }
 etch();
}
OUTPUT:-

Enter Number(Minimum 4 and Max 7): 5
** **** ****** **** ****** ******** ********** ****** ******** ********** ************ ************** | | | |

program will work as follows,