I'm new to C++ and i was trying to understand how to work with arrays. The idea I have is
1) I wanted a user to input an array, the program to output the array
2) Double all the values in the array and output that
3) And for each of the doubled values, add the digits of the doubled number (1 digit would remain the same), then output the new numbers as well.
(e.g. if the Nth array value was 8, then 8*2=16. Then the program would perform 1+6=7)
I put my code to show my progress, feel free to point out any errors along the way!
OK I understand now.
Easiest would be to create a function int sum_of_digits(int num) and call it for each value in the doubled array and store the value in the final array.
If you are not allowed to use functions then try this;
1 2 3 4 5 6 7 8 9 10 11 12
cout << "When the digits of each seat are added..." << endl;
for (int k=0;k<maxNum;k++)
{
int num = num[k];
int sum = 0;
while (num !=0 )
{
sum += num % 10;
num = num / 10;
}
num[k] = sum
}