We will create a C program to output this tree:
Here is the source code:
I hope you had fun with this tree. :) You may decorate the tree with your own program. I will explain the program if you want. To get explanation just comment here.
Here is the source code:
/* Tree.c */ #include <stdio.h> int main() { int row,j, i,space,star; int n = 12; for(row=0;row<n;row++){ star = 2*row + 1; space = (2*n - 1 - star) / 2; for(i=0;i<space;i++) printf(" "); for(i=0;i<star;i++) printf("*"); for(i=0;i<space;i++) printf(" "); printf("\n"); } for(row=12;row<15;row++){ star=3; space=10; for(i=0;i<space;i++) printf(" "); for(i=0;i<star;i++) printf("*"); for(i=0;i<space;i++) printf(" "); printf("\n"); } return 0; }
I hope you had fun with this tree. :) You may decorate the tree with your own program. I will explain the program if you want. To get explanation just comment here.
0 comments :
Post a Comment
Spam comments will be deleted. :)