First, you have to extract the individual digits from the original value of b so that they can be added together. Do that in a loop using the mod operator % to extract the right-most digit then divide by 10 to shift all digits right
int x = 0;
int b = 01234;
x += b % 10; // get right-most digit and save in x
b /= 10; // truncate right-most digit
once you get that working for both b and h come back and we'll work on the rest of the problem (unless of course you can do it yourself)