Thread: Christmas with a capital C...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547

    Christmas with a capital C...

    It's your Christmas card.
    Copy, compile, enjoy...

    Code:
    // The 12 days of christmas C style
    #include <stdio.h>
    
    int main (void)
      { int day; 
        char days[12][12] = {"first", "second", "third", "fourth", "fifth", "sixth",
                          "seventh", "eighth", "nineth", "tenth", "eleventh", "twelth" };
    
        do
          {
            printf("Which day of Christmas is it? (1 - 12) : ");
            scanf("%d",&day);
            while(getchar() != '\n');
          }  
        while((day < 1) || (day > 12)); 
     
        printf("\n\nOn the %s day of Christmas my true love gave to me...\n",days[day-1]);
    
        switch(day) 
          {
            case 12 :
              printf("\t12 drummers drumming\n");
            case 11 :
              printf("\t11 pipers piping\n");
            case 10 :
              printf("\t10 lords a leaping\n");
            case 9 :
              printf("\t9 ladies dancing\n");
            case 8 :
              printf("\t8 maids a milding\n");
            case 7 :
              printf("\t7 swans a swimming\n");
            case 6 :
              printf("\t6 geese a laying\n");
            case 5 :
              printf("\t5 GOLDEN RINGS\n");
            case 4 :
              printf("\t4 calling birds\n");
            case 3 :
              printf("\t3 french hens\n");
            case 2 :
              printf("\t2 turtle doves\n");
            case 1 :
              if (day > 1)
                printf("\t...and...\n");
              printf("\ta partrige in a pear tree!\n");
          }
    
        printf("\nHappy holidays to all on CProgramming!\n");
        return 0;
      }
    Last edited by CommonTater; 12-18-2011 at 11:24 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why capital letters in function
    By vrkiller in forum C++ Programming
    Replies: 2
    Last Post: 02-19-2011, 01:21 PM
  2. Capital Letters?
    By MiroMage in forum C Programming
    Replies: 8
    Last Post: 11-05-2008, 04:32 PM
  3. Capital Letters ...
    By twomers in forum C++ Programming
    Replies: 11
    Last Post: 01-11-2006, 03:10 AM
  4. How To Make Capital Letter To Small Capital Letter??
    By jason07 in forum C++ Programming
    Replies: 3
    Last Post: 10-10-2005, 04:37 PM
  5. check for capital letters
    By blackwyvern in forum C++ Programming
    Replies: 3
    Last Post: 01-30-2002, 10:32 PM