Christmas tree constructer ♥
#include<iostream.h>
#include<conio.h>
class tree
{
private:
int m,n,i,j,k;
public:
tree(int,int);
void display()
{
for(i=m;i<=n;i++)
{
for(k=m;k<=n-i;k++)
{
cout<<" ";
}
for(j=m;j<=i;j++)
{
cout<<" "<<"*";
}
cout<<"\n";
}
}
};
tree::tree(int x,int y)
{
m=x;
n=y;
}
void main()
{
clrscr();
tree t1(1,5);
tree t2(1,5);
tree t3(1,5);
t1.display();
t2.display();
t3.display();
getch();
}
Here is the output :)
No comments:
Post a Comment