Hi

i wanted to know how to convert an array of ints to a single int, for example:

how can i do that?? help plsCode:`//I want to convert this:`

int a[20]={4,2,4,5,6,1,2};

//to this:

int c=4245612;

Printable View

- 06-10-2010shiroaisuconverting Int array to a single int
Hi

i wanted to know how to convert an array of ints to a single int, for example:

Code:`//I want to convert this:`

int a[20]={4,2,4,5,6,1,2};

//to this:

int c=4245612;

- 06-10-2010zacs7
Did you forget how the decimal system works?

Each place is a power of 10, simply multiply each element by 10 to its respective place. So,

Code:`{4,2,4,5,6,1,2} = (10^6 * 4) + (10^5 * 2) + (10^4 * 4) + (10^3 * 5) + (10^2 * 6) + (10^1 * 1) + (10^0 * 2)`

- 06-11-2010shiroaisu
Tks man :) solved