I need to convert integer into a binary form, so far I have this code which convert it , but in a reverse order and I cannot reverse it in a right order . PS you cannot use array or any others data structures which is frustrating , you can also use while , do while or for loop. Sorry for my bad English in advance
1 2 3 4 5 6 7
int number=12;
int newNumber=0;
while (number!=0){
int remainder=number%2;
newNumber=number/2;
number=newNumber;
std::cout<<remainder<<" ";
Well the funny think is that we did not cover functions yet and he does not want us to use it. He only allows us to use decisions such us if and else and loops.Well is that possible to do with a third variable
Hash table? I do not know how that would be useful in this case.
Anyway, if you want to "cheat" you could just use the std::bitset container.
You could also use the std::hex manipulator with a hex-to-bin conversion table.