It is quite simple, indeed.

```
int main()
{
    int n,i,j;
    n = 20;
    i = 0;
    char ch[8];

    do
    {
        ch[i] = (n%2) + '0';
        n /= 2;
        // SIMPLE WAY
        if(n != 0)
            i++;
    }
    while(n != 0);

    for(j=0; j<=i; j++)
    {
        printf("%c",ch[i-j]);
    }

    return 0;
}

```

But i don't like this WAY

I tried the below WAY but code is bad

```
int main()
{
    int n,i,j;
    n = 20;
    i = 0;
    char ch[8];

    do
    {
        ch[i] = (n%2) + '0';
        n /= 2;
    }
    while(n != 0 && i++); // THIS

    for(j=0; j<=i; j++)
    {
        printf("%c",ch[i-j]);
    }

    return 0;
}

```

How to get the value incremented only when the loop is true with BEST WAY?
OR just correct 2nd way `while(n != 0 && i++)`