Converting int into char array.

You could do the maths (get the modulus of 10 etc.) but the simplest is probably to do sprintf into a buffer.

eg.

char buf [4];
sprintf (buf, "%03i", finalval);

Then you just subtract '0' from each digit to get the "binary" number.

eg.

int digit1, digit2, digit3

digit1 = buf [0] - '0';
digit2 = buf [1] - '0';
digit3 = buf [2] - '0';

The code above assumes that finalval won't exceed 999.