62 : C Program to display Christmas tree sequence 10

Check out the complete list of c-programs : C Program List    





To generate a Christmas xmas tree of asterisks we need two pyramids and stem of stars and a base.

We can make the upper pyramid smaller by having the number of rows less compaired to the below one.

      *

     ***

    *****

   *******

  *********

      *

     ***

    *****

   *******

  *********

 ***********

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

     **

     **

     **

     **

     **

     **

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







/*
 * 1000+ C programs + tutorials
 *
 * 
 * 61_c_program_to_display_christmas_tree_stars_9.c
 *  
 *
 *
 *  Created on: Oct 22, 2014
 *  Author: Code2care.org
 */

#include 
//#include 

void main() {


//clrscr();

int rows = 5;
int space =6;
int i,j,k;



 
  for (i = 1; i <= rows; i++)
  {
    for (j = 1; j <= space; j++)
      printf(" ");
 
    space--;
 
    for (k = 1; k <= 2*i-1; k++)
      printf("*");
 
    printf("\n");
  }
  
rows = 7;
space =6;
 
  for (i = 1; i <= rows; i++)
  {
    for (j = 1; j <= space; j++)
      printf(" ");
 
    space--;
 
    for (k = 1; k <= 2*i-1; k++)
      printf("*");
 
    printf("\n");
  }
 

        
printf("     **\n");
printf("     **\n");
printf("     **\n");
printf("     **\n");
printf("     **\n");
printf("     **\n");
printf("*************\n");

       

//	getch();


}









The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.