C Program to Print Christmas Tree Star Pattern

C Program to Print Christmas Tree Star Pattern

Program to print christmas tree star pattern in c; Through this tutorial, we will learn how to print christmas tree star pattern in c program.

C Program to Print Christmas Tree Star Pattern

#include <stdio.h>
int n=10;
int main()
{
  int i,j,m;
  float k;

  m=n-1;
  for(i=0;i<n;i++)
  {
    for(j=0;j<(m+2*n);j++)
    {
      printf(" ");
    }
    m--;

    for(k=0;k<=i;k+=0.5)
    {
    printf("*");
    }
    printf("\n");
  }

  m=n-1;
  for(i=0;i<n;i++)
  {
    for(j=0;j<((m+(2*n))-5);j++)
    {
      printf(" ");
    }
    m--;

    for(k=0;k<(i+6);k+=0.5)
    {
    printf("*");
    }
    printf("\n");
  }

  m=n-1;
  for(i=0;i<n;i++)
  {
    for(j=0;j<((m+(2*n))-9);j++)
    {
      printf(" ");
    }
    m--;

    for(k=0;k<(i+10);k+=0.5)
    {
    printf("*");
    }
    printf("\n");
  }

  for(i=0;i<(n-n/2);i++)
  {
    for(j=0;j<((3*n)-3);j++)
    {
      printf(" ");
    }

    for(k=0;k<6;k++)
    {
    printf("*");
    }
    printf("\n");
  }

  return 0;
}

The output of the above c program; is as follows:

                   *
                  ***
                 *****
                *******
               *********
              ***********
             *************
            ***************
           *****************
          *******************
              ************
             ************** 
            ****************
           ******************
          ********************
         **********************
        ************************
       **************************
      ****************************
     ******************************
          ********************
         **********************
        ************************
       **************************
      ****************************
     ******************************
    ********************************
   **********************************
  ************************************
 **************************************
                 ******
                 ******
                 ******
                 ******
                 ******

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *