[Solved] Having trouble converting a decimal into a binary in C. No output [closed]


int main()
{
    int k=0, i, r, nr, c, N[64];
    printf("Decimal Nr: "); scanf("%d", &nr);
    c = nr;
    if(nr==0)
      printf("0");
    else{
    while (nr) {
        r = nr % 2;
        nr = nr / 2;
        N[k] = r; k++;
      }
    }
    // original number in variable c
    for (i = k-1; i >= 0; i--) {
        printf("%d ", N[i]);
    }
    return 0;
}

Just try to understand what the algorithm does. And be careful when you code terminating conditions.

23

solved Having trouble converting a decimal into a binary in C. No output [closed]