I am a total newcomer to the world of C++, and not much more experienced in any other languages, so please forgive me for the bad syntax and indentation etc etc...
Can someone please explain to me why this simple program will print the array values that I input, but won't add up the array values?
#include <iostream>
using namespace std;
int main(){
int alpha[8];
int sum=0;
for(int x=0; x<8; x++){
cin>>alpha[x];
}
for(int x=0; x<8; x++){
cout<<alpha[x];
sum += alpha[x];
return sum;
}
cout<<sum;
return 0;
}