Decimal to binary array
Some comments:


There is no need to store the results in memory, so don't. Simply output them as they are computed.
It's been many years since C has allowed variables to be declared where they're used instead of being lumped together at the top. Do this for legibility.
Don't loop through to get q. Powers of 2 are easily found via &lt;&lt; .
Don't loop through to reset the array contents to 0. Simply set the elements to their desired value.
Don't populate an array forward and then loop back through it in reverse to do an output. Simply populate a string that is ready to be output.
f doesn't mean anything to the program user, so don't use it in the output; use something like "decimal" instead.


An alternative implementation is:

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int main()
{
    int n;
    scanf("%d", &amp;n);

    char *output = malloc(n+1);
    output[n] = '\0';

    for (int number = 0; number &lt; (1 &lt;&lt; n); number++)
    {
        int temp_num = number;
        for (int idx = n-1; idx &gt;= 0; idx--)
        {
            output[idx] = '0' + (temp_num &amp; 1);
            temp_num &gt;&gt;= 1;
        }
        printf("dec: %d bin: %s\n", number, output);
    }
    return 0;   
}