Hi guys, I'm writing my first intro programming midterm tomorrow, and need a little help with arrays. This is my first time programming so I'm very new.
I want to create a program that stores 10 numbers (from input) into an array, and display the sum of those numbers. However, when I compile the code that I make, no matter what my input values are, I always end up with the answer 5373728.
Is there any specific reason for this? From what I can tell the code looks good, mabye its just a problem with my compiler? Any help before my midterm would be much appreciated. Thanks :)
#include <iostream>
#include <cmath>
using namespace std;
#include <iostream>
#include <cmath>//you don't need this in this case.
usingnamespace std;
int main()
{
int sum=0, a[10];
int i = 0;
for (i; i<10; i++)
{
cin >> a[i];
}
for(i=0;i<10;i++)
sum += a[i];
cout<< sum<<endl;
return (0);
}