Create a christmas tree use C

 Create a christmas tree use C language very simple step.


#include<stdio.h>

int main()

{    

int i,j,k,s=50,c;

for(i=1;i<=5;i++)   //first loop

{

for(k=1;k<=s;k++)

{

printf(" ");

    }

  s=s-1;

  for(j=1;j<=i;j++)

    {

    printf("*");

        }

        //printf("\n");

        for(c=1;c<=i;c++)

        {

        printf("*");

}

printf("\n");

    }

    int i1,j1,k1,s1=49,c1;   //secand loop

    for(i1=2;i1<=6;i1++)

    {

    for(k1=1;k1<=s1;k1++)

    {

    printf(" ");

}

s1=s1-1;

for(j1=1;j1<=i1;j1++)

{

printf("*");

}

for(c1=1;c1<=i1;c1++)

{

printf("*");

}

printf("\n");

}

int i2,j2,k2,s2=48,c2;     //third loop

    for(i2=3;i2<=7;i2++)

    {

    for(k2=1;k2<=s2;k2++)

    {

    printf(" ");

}

s2=s2-1;

for(j2=1;j2<=i2;j2++)

{

printf("*");

}

for(c2=1;c2<=i2;c2++)

{

printf("*");

}

printf("\n");

}

int i3,j3,k3,s3=47,c3;     //forth loop

    for(i3=4;i3<=8;i3++)

    {

    for(k3=1;k3<=s3;k3++)

    {

    printf(" ");

}

s3=s3-1;

for(j3=1;j3<=i3;j3++)

{

printf("*");

}

for(c3=1;c3<=i3;c3++)

{

printf("*");

}

printf("\n");

}

int i4,j4,k4,s4=48,c4; //forth loop

    for(i4=1;i4<=5;i4++)

    {

      for(k4=1;k4<=s4;k4++)

      {

      printf(" ");

  }

      for(j4=5;j4>=0;j4--)

      {

    printf("#");

  }


        printf("\n");

   }

}


Output program


Thank you.

Comments

Popular posts from this blog

Write a program to calculate the bill amount for an item given its quantity sold, value, discount ,and tax.

Bank Atm project using C Programming

Indian Flag INDEPENDENCE DAY SPECIAL CODING