C Program To Print Christmas Tree
Learn how to write a code to print Christmas tree in C programming language. This Christmas tree program makes use of for Loops primarily which makes it much more easier to write a C code to display a Christmas tree.
This program prints asterisks to draw the X – Mas tree. However, you can use any other character that you wish to display this Christmas tree in C programming.
Note: This C program to display a Christmas tree is compiled with GNU GCC compiler on Ubuntu 14.04 operating system. However, it is compatible with all other operating systems.
Must Read: Java Program To Display Christmas Tree
C Program To Print Christmas Tree
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #include<stdio.h> int main() { int limit = 30, temp; int i, j; printf("\n"); temp = limit/4; for(i = 1; i <= limit/4; i++) { printf("\t\t "); for(j = 1; j < temp; j++) { printf(" "); } temp--; for(j = 1; j <= 2*i-1; j++) { printf("*"); } printf("\n"); } temp = limit/3; for(i = 3; i <= limit/3; i++) { printf("\t "); for(j = 1; j < temp; j++) { printf(" "); } temp--; for(j = 1; j <= 2*i-1; j++) { printf("*"); } printf("\n"); } temp = limit/2; for(i = 4; i <= limit/2; i++) { printf("\t"); for(j = 1; j < temp; j++) { printf(" "); } temp--; for(j = 1; j <= 2*i-1; j++) { printf("*"); } printf("\n"); } for(i = 0; i < limit/3; i++) { printf("\t\t "); printf("*****"); printf("\n"); } printf("\t\t *************"); printf("\n\t\t *************"); printf("\n"); return 0; } |
Also Read: Print Map of India in C Programming
Output

Let’s discuss more on this C program for printing a Christmas tree in the comment section below if you have any compilation errors or doubts about the same.
Nice
how to print it in single stand structure
Try removing the last 3 print statements!!
Is it for TCS CodeVita Competition 2016?
Finally I found a working C Program for Printing a Christmas Tree that too with easy understandable syntax. Thanks.
I hope you this program could help you in your Codevita competition.
Thank you so much! This program helped me in TCS CodeVita – 2016 Competitive Exam! It was too difficult but I could get some help from this site.
It’s good not bad as it is thank you so much creating this websites
This is one of the most easiest c programming codes for printing christmas tree. Thank you.
Thanks. I could finally print a tree in c programming for my Hackerrank competition. This is really a simple code.