Q:

C Program For Draw A Perfect Christmas Tree

belongs to collection: Patterns Basic C Programs

0

Christmas Tree :- 

Christmas Tree The tree was traditionally decorated with edibles such as apples, nuts, or other foods or an artificial tree of similar appearance, associated with the celebration of Christmas

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
#include<conio.h>
//#include<iostream>
//using namespace std;
int main()
{
int i,j;
int  no,abc;
char last;
 printf("Enter The Value 30 For Perfact Chrismas Treen\n\n ");
 scanf("%d",&no);
 printf("\n");
 do//Do-While Loop Start From Here
  { 
  abc=no/4;
  for(i=1; i<=no/4; i++)
   {
   printf("\t\t  ");
   for(j=1; j<abc; j++)
    printf(" ");
    abc--;
     for(j=1; j<=2*i-1; j++)
      printf("*");
       printf("\n");
 }

 abc=no/3;
 for(i=3; i<=no/3; i++)
  {
  printf("\t     ");
   for(j=1; j<abc; j++)
    printf(" ");
    abc--;
     for(j=1; j<=2*i-1; j++)
      printf("*");
      printf("\n");
  }

 abc=no/2;
 for(i=4; i<=no/2; i++)
  {
  printf("\t");
   for(j=1; j<abc; j++)
    printf(" ");
    abc--;
     for(j=1; j<=2*i-1; j++)
      printf("*");//Enter The AnyThing In Place Of ( * ) Like Any Key For Change Pattern
      printf("\n");
  }

 for(i=0;i<no/3;i++)
  {
  printf("\t\t      ");//Extra Space For Maintain Tree 
  printf("*****");//Enter The AnyThing In Place Of ( * ) Like Any Key For Change Pattern
  printf("\n");
  }
  
  printf("\t\t  *************");//Enter The AnyThing In Place Of ( * ) Like Any Key For Change Pattern
  printf("\nPress Y Or y Number For Again Print Tree N Or Other Key For Exit :");
  scanf("%c",&last);
 }
 while(last=='Y'||last=='y');

 getch();
 return 0;
}

 

Output:

Enter The Value 30 For Perfact Chrismas Treen

 30

        *

       ***

      *****

     *******

    *********

   ***********

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

              *****

             *******

            *********

           ***********

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

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

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

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

              *******

             *********

            ***********

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

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

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

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

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

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

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

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

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

      *****

      *****

      *****

      *****

      *****

      *****

      *****

      *****

      *****

      *****

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

Press Y Or y Number For Again Print Tree N Or Other Key For Exit :

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
<< C Program For Print A Left Pascal Triangle Using N...