I am doing a homework assignment in which we have to get an undetermained amount of numbers from the user. I was wondering how to tell when the user is done entering numbers and wants to exit the loop, such as perhaps a blank space or a word like 'quit'.
Here is what I have so far, I used 72 as the exit number just as a test.
Thank you.Code:// Function Used to Get Numbers into Array int calcList() { for (int i=0; i<100; i++) { std::cout << "Enter an integer: "; std::cin >> list[i]; counter = counter + 1; // Exit Loop When 72 is Inputed if (list[i]== 72) { return(0); } } }




Reply With Quote