I need help with arrays! :/

So I've got a code where the player inputs the amount of numbers for the list then will have to input the numbers for list they decided it to be. However, i manage to get the sum to add the total. It's just finding the lowest number to the largest number And I can't find anything about it.

You are viewing a single comment. View All
Answered by themaka (183) [earned 5 cycles]
Wo1ves1n0 (5)

@themaka /
Computational Thinking
Assigment 3 template
"Torren Walker"
/

#include <iostream>
using namespace std; // cout instead of std::

int main() //Main body for the code
{

int sum=0; //Sum for where to start 0 = starting point
int length = 0; //integer used to create the length of the array
cout << "How many numbers are you checking for?: ";
cin >> length; // the amount of numbers for the list

int MyList[length]; //Array is created using the value of length

for (int i=0; i<length; i++) //For loop to enter values into the array
{
cout << "Enter number " << i+1 << ": ";
cin >> MyList[i];
}

``cout << endl << "Printing Array"<< endl << "--------------" << endl; // text``

for (int i=0; i<length; i++) //For loop to enter values into the array
{
sum+=MyList[i]; // Adds the list that the user as given the integer for
cout << MyList[i] << endl; // puts the list together of what the user has entered.
}
cout << "--------------" << endl << "Adding your list of numbers" << endl;//Caption
cout << "Total: " << sum << endl; // the total for the list added

``return 0;``

}