In C language Write a program that prompts the user for the
In C language!!!
Write a program that prompts the user for the number of days, then print the lyrics for the entire song for that number of days. Your program must work for any day between 1 and 12. You can use either the standard version or Bob and Doug\'s version).Use MUST use a nested loop, here is some partial code://get number of days from user for(verse = 1; verse = 1; line--) {//switch on line goes here//each case will have a printf for that line}}Solution
Please foloow the code and comments for description :
CODE :
#include <stdio.h> // required header files
int main() // driver method
 {
 int days; // local varaibles
 printf(\"Please Enter how many Days : \"); // prompt for the user
 scanf(\"%d\", &days); // get the days
 int verse = 0, line = 0; // local varaibles
 for(verse = 1; verse <= days; verse++) { // outer loop for the verses
 for(line = verse; line >= 1; line--) { // inner loop for the lines
 switch(line) { // switch case statements
 case 1 :
 printf(\"\ On the first day of Christmas, my true love gave to me,\ A Beer.\");
 break;
 case 2 :
 printf(\"\ On the second day of Christmas, my true love gave to me,\ Two turtle-necks.\ \");
 printf(\"A Beer\");
 break;
 case 3 :
 printf(\"\ On the third day of Christmas, my true love gave to me,\ Three French toast.\ Two turtle-necks.\ \");
 printf(\"A Beer\");
 break;
 case 4 :
 printf(\"\ On the fourth day of Christmas, my true love gave to me,\ Four pounds of back-bacon.\ Three French toast.\ Two turtle-necks.\ \");
 printf(\"A Beer\");
 break;
 case 5 :
 printf(\"\ On the fifth day of Christmas, my true love gave to me,\ Five golden toques.\ Four pounds of back-bacon.\ Three French toast.\ Two turtle-necks.\ \");
 printf(\"A Beer\");
 break;
 case 6 :
 printf(\"\ On the sixth day of Christmas, my true love gave to me,\ Six packs of Tuborg.\ Five golden toques.\ Four pounds of back-bacon.\ Three French toast.\ Two turtle-necks.\ \");
 printf(\"A Beer\");
 break;
 case 7 :
 printf(\"\ On the seventh day of Christmas, my true love gave to me,\ Seven pack of smokes.\ Six packs of Tuborg.\ Five golden toques.\ Four pounds of back-bacon.\ Three French toast.\ Two turtle-necks.\ \");
 printf(\"A Beer\");
 break;
 case 8 :
 printf(\"\ On the eighth day of Christmas, my true love gave to me,\ Eight comic books.\");
 printf(\"\ Seven pack of smokes.\ Six packs of Tuborg.\ Five golden toques.\ Four pounds of back-bacon.\ Three French toast.\ Two turtle-necks.\ \");
 printf(\"A Beer.\ On my tree!\ Yeah. That beer\'s empty. Okay. Day,\ Twelve.!\");
 break;
 case 9 ... 12 :
 printf(\"\ Uh, twelve.\ Good day, and welcome to day twelve.\ Five golden touques!\ Four pounds of backbacon,\ three French toast,\ two turtlenecks,\ and a beer, in a treeeeeeeeeeeeeeeeeeeeeee!\");
 printf(\"\ Beauty, eh?\ Where\'d you learn to do that?\ Uh, albums.\ So, like, that\'s our song, Merry Christmas...\ Merry Christmas!\ And good day!\ Good day, everybody.\");
 printf(\"\ Happy New Year, too.\ Sheesh. Okay, you know what you left out?\ What?\ Donuts - I told you to get me donuts!\ Either on the ninth day or the tenth day, or the eleventh day, I wanted donuts.\");
 printf(\"\ Okay, the song\'s over.\ But I want...\ Merry Christmas, everybody!\ Or on the twelfth day, you coulda got me a dozen donuts.\ So, go out to the stores, and get some presents.\");
 printf(\"\ You coulda gone down to, like, the good donut shop, where if you buy a dozen, you get another one free, and then thirteen for the thirteen days of Christmas.\");
 printf(\"\ Well, next Christmas, I\'ll get me a chainsaw...\ Take off!\ that song was a beauty. It moved me...\ Yeah, I think it ranks up there with Stairway to Heaven...\ What?\ \");
 break;
 }
 break;
 }
 }
 return 0;
 }
OUTPUT :
Please Enter how many Days : 5
 On the first day of Christmas, my true love gave to me,
 A Beer.
 On the second day of Christmas, my true love gave to me,
 Two turtle-necks.
 A Beer
 On the third day of Christmas, my true love gave to me,
 Three French toast.
 Two turtle-necks.
 A Beer
 On the fourth day of Christmas, my true love gave to me,
 Four pounds of back-bacon.
 Three French toast.
 Two turtle-necks.
 A Beer
 On the fifth day of Christmas, my true love gave to me,
 Five golden toques.
 Four pounds of back-bacon.
 Three French toast.
 Two turtle-necks.
 A Beer
 Hope this is helpful.


