I set myself the following additional goal (devised by me):
I have never programmed before and hence decided that in order to get used to c++, particularly the syntax I would make a short quiz to determine which Disney princess you are by answering two questions. I used the example from section 3.2 in the handout as a basis and modified it to perform the task I wanted as well as annotating using // to make sure I understood what was happening in each line.
//Instruction to the compiler's preprocessor to include iostream definitions. #include//Specifing names in the program are defined by the c++ libraries using namespace std; //Specifing that main body of the program is beginning and will end with an integer (2 in this case) int main () { // declaring variables which are integers int hair, a, b, c; // first question cout is used to output a statement and cin to read data. cout << " What best describes your hair? 1. black 2. blonde/white 3. ginger/brown " << endl ; cin >> hair; // determining the result if (hair == 1) { cout << " Which is your favourite animal? 1. dragon 2. bird 3. racoon 4. frog 5. tiger " << endl ; cin >> a; if (a == 1){ cout << " Mulan " ; } if (a == 2) { cout << " Snow White " ; } if (a == 3) { cout << " Pocahontas " ; } if (a == 4) { cout << " Tiana " ; } if (a == 5) { cout << " Jasmine " ; } } if (hair == 2){ cout << " Which is your favourite animal? 1. reindeer 2. lizard 3. mouse 4. owl " << endl ; cin >> b; if (b == 1) { cout << " Elsa " ; } if (b == 2) { cout << " Rapunzel " ; } if (b == 3) { cout << " Cinderella " ; } if (b == 4) { cout << " Aurora " ; } } if (hair == 3) { cout << " Which is your favourite animal? 1. bear 2. fish 3. reindeer 4. horse" << endl ; cin >> c; if (c == 1){ cout << " Merida " ; } if (c == 2) { cout << " Ariel " ; } if (c == 3) { cout << " Anna " ; } if (c == 4) { cout << " Belle " ; } } // terminate the program: return 2; }