Issue converting decimal to binary

I am supposed to ask the user for a low number, and a high number. Then, the numbers should print, and each number in the range should print its binary as well. (using a while loop) I am struggling to figure out how to structure the while loop to properly spit out the binary. I am new to CPP so any help would be appreciated!

If low and high are 1 and 10, I would want it to print:
1 1
2 10
3 11
4 100
... and so on.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Unit 5.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main()
{

	int lowNum;
	cout << "Please enter your low number (only use numbers 1 - 256): ";
	cin >> lowNum;

	while (lowNum < 1 || lowNum > 256)
	{
		cout << "Please only enter numbers between 1 and 256: ";
		cin >> lowNum;
		while (cin.fail())
			cin.clear();
			cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
	}

	int highNum;
	cout << "Please enter your high number (only use numbers 1 - 256): ";
	cin >> highNum;

	while (highNum <= lowNum)
	{
		{
			cout << "Please ensure that the high number you enter is bigger than your low number: ";
			cin >> highNum;
		}

		while (highNum < 1 || highNum > 256)
		{
			cout << "Please only enter numbers between 1 and 256: ";
			cin >> highNum;
			if (cin.fail())
				cin.clear();
			cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
		}
	}
	int saveLow = lowNum;
	int current = 0;
	while (current < highNum)
	{
		current = lowNum;
		cout << current << endl;
		lowNum += 1;
	}

	int bin;
	int count = saveLow;
	while (lowNum > 0)
	{
		bin = lowNum % 2;
		cout << bin;
		lowNum /= 2;
		count += 1;

	}


    return 0;
}

Topic archived. No new replies allowed.