fork download
  1. #include<stdio.h>
  2. void partsf();
  3. void branches();
  4. void stand();
  5. int n;
  6. int parts;
  7.  
  8. int main()
  9. {
  10. printf("enter no. of days");
  11. scanf("%d",&n);
  12. parts= n-1;
  13. if(n<=1)
  14. printf("you cannot generate christmas tree");
  15. else if(n>20)
  16. printf("tree is no more");
  17. else{
  18. partsf();
  19. stand();
  20. return 0;
  21. }
  22. }
  23.  
  24.  
  25. void partsf(){
  26. int i;
  27. for(i=parts;i>0;i--){
  28. if(i==parts)
  29. branches(n+1,1,n);
  30. else if(i==parts-1)
  31. branches(n-1,3,n-1) ;
  32. else if(i==1)
  33. branches(n-2,3,n-1);
  34. else
  35. branches(n-1,3,n-1);
  36. }}
  37.  
  38. void branches(int k , int leaf,int space)
  39. {
  40. int j,temp ;
  41. while(k!=0){
  42. temp=space;
  43. while(space!=0){
  44. printf(" ");
  45. space--;
  46. }
  47. for(j=1 ; j<=leaf ; j++)
  48. printf("*");
  49. printf("\n");
  50. leaf=leaf+2;
  51. k--;
  52. space = temp-1;
  53.  
  54. }
  55. }
  56.  
  57. void stand(){
  58. int i=2;
  59. int m;
  60. while(i!=0){
  61. m=n;
  62. while(m!=0) {
  63. printf(" ");
  64. m--;}
  65. printf("*\n");
  66. i--;
  67. }
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:20:1: warning: implicit declaration of function 'getch' [-Wimplicit-function-declaration]
 getch();
 ^
/home/Qme9Pm/ccdOKBAw.o: In function `main':
prog.c:(.text.startup+0x52): undefined reference to `getch'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty