Need some help with a program...
I am pretty new to C++ and the whole programming bit. I am trying to write a program that will display the "Twelve Days of Christmas" song, and need some help... I see there is a problem using apstring to intialize day_of_christmas, and don't know what else to use. Any help is appreciated! Thanks in advance!
Code:
/*
Josh
christmas.cpp
*/
#include <iostream.h>
#include <apstring.h>
int main()
{
apstring day_of_christmas;
switch(day_of_christmas) {
case 12:
cout << "Twelth";
case 11:
cout << "Eleventh";
case 10:
cout << "Tenth";
case 9:
cout << "Ninth";
case 8:
cout << "Eighth";
case 7:
cout << "Seventh";
case 6:
cout << "Sixth";
case 5:
cout << "Fifth";
case 4:
cout << "Fourth";
case 3:
cout << "Third";
case 2:
cout << "Second";
case 1:
cout << "First";
}
cout << "On the " << day_of_christmas << " day of Christmas, " << endl;
cout << "My true love gave to me " << endl;
switch(day_of_christmas) {
case 12:
cout << "Twelve drummers drumming";
case 11:
cout << "Eleven pipers piping";
case 10:
cout << "Ten lords a-leaping";
case 9:
cout << "Nine ladies dancing";
case 8:
cout << "Eight maids a-milking";
case 7:
cout << "Seven swans a-swimming";
case 6:
cout << "Six geese a laying";
case 5:
cout << "Five golden rings!";
case 4:
cout << "Four calling birds";
case 3:
cout << "Three french hens";
case 2:
cout << "Two turtle doves";
case 1:
cout << "A partridge in a pear tree";
}
return 0;
}
Re: Need some help with a program...
Well first of all...day_of_christmas never changes. you have switch statement, but it will never run....like saying if day of christmas is 12 then....when it hasn't been set to anything. Put this in a loop and have it increment each time
Quote:
Originally posted by mysteryman
Code:
/*
Josh
christmas.cpp
*/
#include <iostream.h>
#include <apstring.h>
int main()
{
apstring day_of_christmas;
switch(day_of_christmas) {
case 12:
cout << "Twelth";
case 11:
cout << "Eleventh";
case 10:
cout << "Tenth";
case 9:
cout << "Ninth";
case 8:
cout << "Eighth";
case 7:
cout << "Seventh";
case 6:
cout << "Sixth";
case 5:
cout << "Fifth";
case 4:
cout << "Fourth";
case 3:
cout << "Third";
case 2:
cout << "Second";
case 1:
cout << "First";
}
cout << "On the " << day_of_christmas << " day of Christmas, " << endl;
cout << "My true love gave to me " << endl;
switch(day_of_christmas) {
case 12:
cout << "Twelve drummers drumming";
case 11:
cout << "Eleven pipers piping";
case 10:
cout << "Ten lords a-leaping";
case 9:
cout << "Nine ladies dancing";
case 8:
cout << "Eight maids a-milking";
case 7:
cout << "Seven swans a-swimming";
case 6:
cout << "Six geese a laying";
case 5:
cout << "Five golden rings!";
case 4:
cout << "Four calling birds";
case 3:
cout << "Three french hens";
case 2:
cout << "Two turtle doves";
case 1:
cout << "A partridge in a pear tree";
}
return 0;
}
:)