[Solved] Given digits separated into array elements, how can I reassemble the number in an int?


I think you’re over complicating this. Just start at 0 and do powers of 10^((n-1)-i). Like so…

int n = 4; // the number of elements in the arr.
int sum = 0;
for(int i = 0; i < n; i++)
    sum += (arr[i] * pow(10, (n-1)-i)); // here (n-1) = 3
std::cout << sum;

1

solved Given digits separated into array elements, how can I reassemble the number in an int?