Decimal to binary conversion
Ive been trying for days to figure out how to do decimal to binary conversion... ive been trying to modules the number by 2 to get the remainder but my proble is saving the remainders in the right order to be printed... the asignment is as follows, print a table of the binary octal and hexadecimal equivalents from 1 to 256. ive got the octal and hexidecimal down... this is basic C programming.. im only in my 7th week of learning it, can someone please help?? here is the code i have already
Code:
#include <stdio.h>
int main()
{
int x;
for( x = 1; x <= 256; x++ ) {
printf( "%d", x );
printf( "\t" );
printf( "%o", x );
printf( "\t" );
printf( "%x", x );
printf( "\n" );
}
return 0;
}
Thanks for your help!!
Antoni