I want to a write a program that converts a number to binary and hex.I tried to do this but It gives me the wrong result
int n, c, k;
int t = 0;
int binary[8];
for (c = 31; c >= 0; c--) {
k = num >> c;
if (k & 1) {
printf("1");
int binary[t] = 1;
} else {
printf("0");
int binary[t] = 0;
}
++t;
}