Adding numbers in arrays using input
I wrote a program that is supposed to take user input and put the input into an array, and when it is terminated it will add up the numbers in the array. Here is the code, if you can help I will be very grateful. I know it's a lot of (probably crappy) code to look at all at once, but thanks in advance. --------------------------------------------------------------------------------- #include <iostream> using namespace std; int main() { bool play = true; int ans; int array[]{}; int sum; while(play=true){ for(int x=0;;){ cout << "input numbers, input -10 to stop and add them all\n"; cin >> ans; if(ans==-10){ sum += array[x]; cout << sum; play = false; }else{ ans = array[x]; x++; } } } return 0; } ---------------------------------------------------------------------------------