Uploaded by Kristen Joy

12 days of Christmas

advertisement
case 12:
printf("Twelve drummers drumming,\n");
case 11:
printf("Eleven pipers piping,\n");
case 10:
printf("Ten lords a-leaping,\n");
case 9:
printf("Nine ladies dancing,\n");
case 8:
printf("Eight maids a-milking,\n");
case 7:
printf("Seven swans a-swimming,\n");
case 6:
printf("Six geese a-laying,\n");
case 5:
printf("Five golden rings,\n");
case 4:
printf("Four calling birds,\n");
case 3:
printf("Three French hens,\n");
case 2:
printf("Two turtle doves, and\n");
case 1:
printf("A partridge in a pear tree.\n");
break;
START
day = 0
OUTPUT “Enter day of
Christmas:”
INPUT day
switch day
case 12
case 11
OUTPUT “Twelve drummers
drumming”
OUTPUT “Eleven pipers piping”
case 10
case 9
case 8
case 7
case 6
case 5
case 4
case 3
case 2
case 1
default
End switch
ALGORITHM DAY
day --> 0
OUTPUT "Enter the day of Christmas; "
INPUT day
OUTPUT “On the”, day, “of Christmas, my true love sent to me”
SWITCH (day)
CASE 12: OUTPUT “Twelve drummers drumming”
CASE 11: OUTPUT “Eleven pipers piping”
CASE 10: OUTPUT “Ten lords a-leaping”
CASE 9: OUTPUT “Nine ladies dancing”
CASE 8: OUTPUT "Eight maids a-milking”
CASE 7: OUTPUT "Seven swans a-swimming”
#include<stdio.h>
int main(){
int day = 0;
printf("Enter the day of Christmas: ");
scanf("%d",&day);
printf("\n\nOn the %d of christmas, my true love sent to me\n", day);
switch(day){
case 12:
printf("Twelve drummers drumming\n");
case 11:
printf("Eleven pipers piping\n");
case 10:
printf("Ten lords a-leaping\n");
case 9:
printf("Nine ladies dancing\n");
case 8:
printf("Eight maids a milking\n");
case 7:
printf("Seven swans a-swanning\n");
case 6:
printf("Six geese a-laying\n");
case 5:
printf("Five golden rings\n");
case 4:
printf("Four calling birds\n");
case 3:
printf("Three french hens\n");
case 2:
printf("Two turtle doves and\n");
case 1:
printf("A partridge in a pear tree\n");
}
return 0;
}
Download