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;
}