This is a very simple dec2bin program done for KTSI.

#include 
#include 
#include 
 
using namespace std;
 
string dec2bin (int v) {
	if (v > 255) {
		return "";
	}
	else { 
		string bin;
		int oneorzero;
		for(int i=8;i>0;i--) {
			oneorzero = v % 2;
			if (oneorzero == 1) {
				bin = "1" + bin;
			}
			else {
				bin = "0" + bin;
			}
			v /= 2;
 
		}
 
	return bin;
 
	}
}
 
int main(){
    int v;
    do {
        cout << "Wert(ende = -1) = "; if (!(cin >> v)) {
            return 0;
        }
        if (v < 0) break;
        string s = dec2bin(v);
        cout << s << endl; //system("PAUSE"); } while(v >= 0);
    cout << "bye" << endl;
    //system("PAUSE");
    return 0;
}