Please teach me some ways on how to convert an integer to a binary digits. thanks.
Well, show us what you've got so far.
This function, with base 2, will do it. It just needs a main() written for it. #include <stdio.h> #include <stdlib.h> int mkDigit( int number, int base, char* answer ) { char characters[] = { "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }; int remainder, index; if( number == 0 ) return( 0 ); remainder = number % base; number /= base; index = mkDigit( number, base, answer ); answer[ index ] = characters[ remainder ]; return( ++index ); }
i don't think he asked for a program just google how to convert decimal to binary
True, but the algorithm still shows.
tell != teach
I agree with @nczempin above, personally. Please do note we have a new clause in our Code of Conduct that reads "Don’t post only answers - guide the asker to a solution."
Join our real-time social learning platform and learn together with your friends!