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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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