The test
if(total == count)
must be done outside the loop
for (num = 1; num < count; ++num)
24 gets printed because 24 = 1+2+3+4+6+8. In your code, you don't get to verify
12.
Also, for efficiency, you may want to consider replacing this loop with:
for (num = 1; num <= count/2; ++num)