You read the two numbers in the variables "num" and "pattern" in different place value systems both as decimal numbers.
If you want to compare both, both must be in the same place value system. The two place value systems work according to these patterns:
for "pattern":
0001 = 1
0010 = 2
0100 = 4
1000 = 8
for "num":
1 = 1
2 = 2
4 = 4
8 = 8
While for "num" each bit already has its "correct" value, for "pattern" the "correct" value would have to be calculated first. Since the result is to be represented as a dual number and the "correct" value is not required here, it would be more favorable to convert "num" into the same system in which "pattern" already exists.
Then you can compare both and output them decimal with up to 8 leading zeros.
Converting "num" to the desired format is trivially easy, but it is probably a homework that I will not do here.
PS: The suggestion to make strings out of both numbers and compare them would be possible, but much more time consuming, because you would have to convert both numbers and then compare strings.
Finally, one more thing: Since "answer" is obviously a string, it cannot be output with %c.