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?
#include <iostream>
usingnamespace 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;
}