Hello folks:
I'm supposed to write a wack code that prints out the song: "Twelve days of Christmas"
using loops and two switch statements. I have a substantial code ( I think), but the output is
unorganized. With verses scattered everywhere.
This is what I have:
/* This program uses repetition and Switch statements
to print the song "The twelve days of Christmas."
One switch statement is used to print the day
( i.e "First," "Second," , etc). A separate switch statement is
used to print the remainder of the verse*/
Code:
#include <stdio.h>
int main(void)
{
int i, j;
printf(" The Twelve Days of Christmas ");
for( i = 1; i <= 12; i++){
printf("On the ");
switch(i){
case 1:
printf("first");
break;
case 2:
printf("second");
break;
case 3:
printf("third");
break;
case 4:
printf("fourth");
break;
case 5:
printf("fifth");
break;
case 6:
printf("sixth");
break;
case 7:
printf("seventh");
break;
case 8:
printf("eigth");
break;
case 9:
printf("ninth");
break;
case 10:
printf("tenth");
break;
case 11:
printf("eleventh");
break;
case 12:
printf("twelfth");
break;
}
printf(" day of Christmas\n"
"my true love sent to me:\n");
for(j = 1; j <= 12; j++){
switch(j){
case 1:
printf("A Partridge in a Pear Tree\n\n");
break;
case 2:
printf("Two Turtle Doves\n"
" and a Partridge in a Pear Tree\n\n");
case 3:
printf("Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
case 4:
printf("Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
case 5:
printf("Five Golden Rings\n"
"Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
case 6:
printf("Six Geese a Laying\n"
"Five Golden Rings\n"
"Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
case 7:
printf("Seven Swans a Swimming\n"
"Six Geese a Laying\n"
"Five Golden Rings\n"
"Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
case 8:
printf("Eight Maids a Milking\n"
"Seven Swans a Swimming\n"
"Six Geese a Laying\n"
"Five Golden Rings\n"
"Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
case 9:
printf("Nine Ladies Dancing\n"
"Eight Maids a Milking\n"
"Seven Swans a Swimming\n"
"Six Geese a Laying\n"
"Five Golden Rings\n"
"Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
case 10:
printf("Ten Lords a Leaping\n"
"Nine Ladies Dancing\n"
"Eight Maids a Milking\n"
"Seven Swans a Swimming\n"
"Six Geese a Laying\n"
"Five Golden Rings\n"
"Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
case 11:
printf("Eleven Pipers Piping\n"
"Ten Lords a Leaping\n"
"Nine Ladies Dancing\n"
"Eight Maids a Milking\n"
"Seven Swans a Swimming\n"
"Six Geese a Laying\n"
"Five Golden Rings\n"
"Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
case 12:
printf("12 Drummers Drumming\n"
"Eleven Pipers Piping\n"
"Ten Lords a Leaping\n"
"Nine Ladies Dancing\n"
"Eight Maids a Milking\n"
"Seven Swans a Swimming\n"
"Six Geese a Laying\n"
"Five Golden Rings\n"
"Four Calling Birds\n"
"Three French Hens\n"
"Two Turtle Doves\n"
"and a Partridge in a Pear Tree\n\n");
break;
}
}
}
system("pause");
return 0;
}