Type the following lines of C++ code using your favorite text editor. Call the program week.cc (if using g++ on ECF) or week.cpp if using Visual C++ on your home machine. The two exercises have also been posted on my lecture page. //This is our second simple C++ program #include using namespace std; //Lets you use all symbols in the standard namespace //such as cout without the std:: throughout your //program //Even if you take this out, the code will still work //and you won't get any compile-time errors //with most C++ compilers, but do keep it in. typedef enum {SUN = 1, MON, TU, WED, THU, FRI, SAT} day_of_the_week; //#define SUN () //typedef defines a new type //in this case, the type is an enumeration, //this means that the variables of that type can take //any of the values enclosed in the enumeration //normally 0, 1, 2, 3, ... //in the above example 1, 2, 3, 4, ... //You can give the newly defined type any name you want //day_of_the_week is probably suggestive in this case //calling it week (in class) might have been confusing to you, //because the type can only take one of the values in the //enumeration at a given time, not all of these values //at the same time. So let's call it better as day_of_the_week int main(){ int i; int j; int day = MON; switch (day){ case SUN: cout << "Sunday" << endl; break; case MON: cout << "Monday" << endl; break; case TU: cout << "Tuesday"<< endl ; break; case WED: cout << "Wednesday" << endl ; break; case THU: cout << "Thursday" << endl ; break; case FRI: cout << "Friday" << endl ; break; case SAT: cout << "Saturday" << endl ; break; default: cout << "You gave me an invalid day of the week" << endl; } return 0; } Then type the following command at the command prompt: g++ -o week week.cc Then type at the command prompt week to execute your program. Look at the output Attempt the following exercises: Replace the day = MON with day = 2, What happens ? Replace the day = MON with day = 10, What happens ? Delete the first break; What happens ? Delete the first and the second breaks; What happens ? Replace int day = MON with day_of_the_week day = MON; What happens ? Replace then with char day = MON; What happens ? unsigned day = MON; What happens ? Replace the typedef enum {SUN = 1, MON, TU, WED, THU, FRI, SAT} day_of_the_week; with #define SUN 1 #define MON 2 #define TU 3 etc. Then use int day = MON (or THU if you like) or int day = 2; What happens ? Try to reason about the output you get in each case and why you get it. If you don't understand an output, please ask me about it. Then try to do something silly like: #define SUN () Compile (the g++ command above) and see the error that you are getting. Do you get an error about a parenthesis on a line that contains no parenthesis (case SUN) ? That means textual replacement of defined constants. Although you do not see this, the preprocessor (which only acts upon the lines starting with a #) has replaced your constant SUN with the () even if it does not make any sense.