I'm trying to create a loop that allows the user to populate an array through the keyboard and typing a command which allows the user to exit the program after the array has been populated. Here is what I have so far...unfortunately I keep getting errors and I think I know what the problem is. I would need to use something other than "n" because its already been declared as an array in my "while" and "if" statements. How can I modify my code to have the program detect when to exit or not?
// Project 4 2.cpp : main project file.
for(i=0; i < 501; i++)
while (n != -1 && i < 501)
cout << "Please enter all your numbers and type -1 when you are done" << endl;
cin >> n[i];
if( n == -1)
char choice = 'a'; //If this becomes 'y' at any time, we exit the loop.
//Put this in the loop.
std::cout << "Do you wish to quit? y/n \n";
cin >> choice; //Get a choice from the user.
if(choice == 'y')//If the user selects 'y', then break out of the loop.