New Sum of Digits

Jan 7, 2014 at 10:36pm
I'm trying to output all of the digits in an integer with spaces in between, and then output the sum of all the digits.
It isn't compiling correctly. Any suggestions?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 #include <iostream>

using namespace std;

int main(int argc, char** argv) {
	
	int maxSize = 25;
	int numbers[maxSize];
	int sum = 0;
	int num;
	cout << "Please enter an integer. ";
	for (int i = 0; i < maxSize; i++)
		{
			cin >> numbers[num];
		}
	
	for (int i = 0; i < maxSize; i++)
		{
			cout << numbers[num] << " ";
			sum += num;
		}
	
	
	cout << "Sum = " << sum;
		
return 0;
}
Jan 7, 2014 at 10:44pm
Please do not double post. Somebody will help you on your original post.
Topic archived. No new replies allowed.