Decimal to binary array Basically, this program takes a decimal number from 1 to 10, that is the index of power of 2. And turns into an array with \$2^n\$ combinations.

For example: If my decimal is 1, I'll have 2 arrays, [0] and [1], and if my decimal is 2, I'll have 4 combinations, [0 0]; [0 1]; [1 0]; [1 1], and so on. I cannot use break conditions.

#include &lt;stdio.h&gt;

int main() {
    int n, q = 1, i, f, d, p, vet[10]; // n: index; q: combinations; i, f, d, p: ints for operations; 

    scanf ("%d", &amp;n); //index

    for (i = 0; i &lt; n; i++){ // getting total number of comb
        q *= 2;
    }
     n--;

    for (i = 0; i &lt; q; i++){
        f = i;

        for (p = 0; p &lt; 10; p++){   //setting array to 0
            vet[p] = 0;
        }

        while ( f &gt; 0){ 
           p = 1;
           d = 0;

            while (f &gt;= 2*p){
                p *= 2;
                d++;
            }

            vet[d] = 1; //changing position 'd' on array for 1. 
            f -= p;
        }

        // printing results
        printf ("f: %d bin:", i);

        for (p = 0; p &lt; 10; p++)
            printf ("%d", vet[9-p]);

        printf ("\n");
    }
    return 0;
}
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;   
}