C++ Code to write twelve(12) days of Christmas.
#include <iostream>
using namespace std;
int main()
{
for (int day = 1; day <= 12; day++) {
cout << "\nOn the " << day; //repeating lines in every stanza.
cout << " day of Christmas, my true love gave to me:\n";
for (int lyrics=1; lyrics<=day; lyrics++){
switch (lyrics) {
case 1: cout << "A Partridge in a Pear Tree\n";
break;
case 2: cout << "Two Turtle Doves, and\n";
break;
case 3: cout << "Three French Hens\n";
break;
case 4: cout << "Four Calling Birds\n";
break;
case 5: cout << "Five Gold Rings\n";
break;
case 6: cout << "Six Geese a-Laying\n";
break;
case 7: cout << "Seven Swans a-Swimming\n";
break;
case 8: cout << "Eight Maids a-Milking\n";
break;
case 9: cout << "Nine Ladies Dancing\n";
break;
case 10: cout << "Ten Lords a-Leaping\n";
break;
case 11: cout << "Eleven Pipers Piping\n";
break;
case 12: cout << "Twelve Drummers Drumming\n\n";
}
}
}
}
Output:
Stay Blessed!
using namespace std;
int main()
{
for (int day = 1; day <= 12; day++) {
cout << "\nOn the " << day; //repeating lines in every stanza.
cout << " day of Christmas, my true love gave to me:\n";
for (int lyrics=1; lyrics<=day; lyrics++){
switch (lyrics) {
case 1: cout << "A Partridge in a Pear Tree\n";
break;
case 2: cout << "Two Turtle Doves, and\n";
break;
case 3: cout << "Three French Hens\n";
break;
case 4: cout << "Four Calling Birds\n";
break;
case 5: cout << "Five Gold Rings\n";
break;
case 6: cout << "Six Geese a-Laying\n";
break;
case 7: cout << "Seven Swans a-Swimming\n";
break;
case 8: cout << "Eight Maids a-Milking\n";
break;
case 9: cout << "Nine Ladies Dancing\n";
break;
case 10: cout << "Ten Lords a-Leaping\n";
break;
case 11: cout << "Eleven Pipers Piping\n";
break;
case 12: cout << "Twelve Drummers Drumming\n\n";
}
}
}
}
Output:
Stay Blessed!
No comments:
Post a Comment