Calculating the sum of the digits in 2^1000
I see some things that may help you improve your code.

Eliminate "magic numbers"

The code, is full of "magic numbers" -- that is, raw numbers in the code that don't have obvious meaning.  For example, we have this:

int dec[320] = {1, };
// and later ...
for (j = 0; j &lt; 302; j++) {


It's unclear, whether 302 and 320 is just a typo or has some signficance.  Better would be to use a #define for this.  I'd use this:

#define BITS 1000
#define DIGITS 302


Write in idiomatic C

Lines like these are a little peculiar to an experienced C programmer:

dec[q] = dec[q] % 10;
dec[q + 1] = dec[q + 1] + 1;


The idiom instead would be to write them like this:

dec[q] %= 10;
++dec[q + 1];


Avoid potentially expensive operations

Since you're only doubling each digit each pass, it's certain that the maximum possible value is 9*2 = 18, so rather than using the % operator, it's sufficient to simply subtract 10.

Make only a single pass through

There's no need to make two passes through the array for each doubling.  It can be done in a single pass like this:

for (int i = BITS; i; --i) {
    int carry = 0;
    for (int j = 0; j &lt; DIGITS; j++) {
        dec[j] = 2 * dec[j] + carry;
        if (dec[j] &gt; 9) {
            dec[j] -= 10;
            carry = 1;
        } else {
            carry = 0;
        }
    }