Hi, please see questions below. And thanks in advance.
Code:
#include<iostream> using namespace std; enum ANIMALS { MAMMAL, DOG, CAT}; const int NumAnimalTypes = 3; //Whats the purpose of this? int main() { int theArray[NumAnimalTypes]; //Why not put 3 here instead of NumAnimalTypes? Does it have something to do with constant? int choice, i; for(i=0; i<NumAnimalTypes; i++) { cout << "(0)Mammal (1)dog (2)cat: "; cin >> choice; switch(choice) { case DOG: cout << "I am a dog" << endl; break; case CAT: cout << "I am a cat" << endl; break; case MAMMAL: cout << "I am a Mammal" << endl; break; default: cout << "I don't know what I am" << endl; break; } theArray[i] = choice; //assign the choices the user entered to the array's counter i. } //list the choices the user entered for (i=0; i<NumAnimalTypes; i++) cout << theArray[i] << endl; system("pause"); return 0; }
Comment