more C++....
Ok even more C++ from me! how would i make a program that could convert Binary to Hex, or decimal to binary. that sort of thing. would you have something like:
#include <iostream>
using namespace std;
int main()
{
int bin;
int hex;
cout<<"enter numbers blah blah blah\n";
cin>> bin;
cin.ignore();
0000 == 0
0001 == 1
0010 == 2
0011 == 3
0100 == 4
0101 == 5
0110 == 6
so on...
cout<<"your conversion blah blah blah\n" << hex <<"blah blah blah";
return main();
}
cin.get();
}
but then it would be limited to just 6 numbers ( although it wouldnt take long to do the other 9 )
——————note––––––––––––––––
i wrote that code, and binary to hex of the top of my head dont crash your computers trying to fix every syntax error.
This is basic stuff, first you have to be familiar with the language you're using, then find out how to do it algorithmically by hand. Then try to implement the algorithm into your preferred language. Some times the way you do it by hand may not be the best way to accomplish the task. The sign of a decent programmer is to be able to solve problems within the constraints that are given to them.
Here's an example of a function in C++ that take an integer as an argument and outputs the binary equivalent.
void OutputBinary(int dec) {
int x;
for(x = 0; x < 32; x++) {
cout << ((dec>>(31-x)) & 1);
}
cout << "\n";
}
It should work. Depending on the integer you should get unnecessary leading 0's… w/e I was just giving an example.
EDIT: mistyped a word :x