Guest User

xmas.c

a guest
Dec 25th, 2025
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. void putcharn(char character, int i) {
  4.     for(int x = 0; x < i; x++) {
  5.         putchar(character);
  6.     }
  7. }
  8.  
  9. int main(int argc, char *argv[]) {
  10.     int treeWidth = 7;
  11.    
  12.     if (argc > 1) {
  13.         sscanf(argv[1], "%d", &treeWidth);
  14.     }
  15.  
  16.     for (int i = 1; i <= treeWidth; i += 2) {
  17.         putcharn(' ', (treeWidth - i) / 2);
  18.         putcharn('*', i);
  19.         putchar('\n');
  20.     }
  21.  
  22.     putcharn(' ', (treeWidth-1) / 2);
  23.     printf("|\n");
  24.     printf("* Merry Christmas, and a happy New Year! *\n");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment