Categories
Translation function from 10 to 2 in C?
Good day. Maybe someone in the snippets has the function of converting from 10th to 2nd number system in C, please share. Thanks in advance.
Answer the question
In order to leave comments, you need to log in
int dec2bin(int num) { int bin = 0, k = 1; while (num) { bin += (num % 2) * k; k *= 10; num /= 2; } return bin; }
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question