I have a simple program that converts decimal numbers to binary numbers. No errors come up when I run the program but I do get a single question mark. I should get a set of values like "00101" I am trying to use a function that returns a string as well. Here is my code,
#include <iostream>
using namespace std;
#include <string>
string convert(int num)
{
string binary;
int remainder;
while (num !=0 )
{
remainder = num % 2;
num = num / 2;
binary = remainder;
}
return binary;
}
int main()
{
int number;
string binaryNum;
cout << "Enter a Number:";
cin >> number;
binaryNum = convert(number);
cout << "This is your number in binary form:" << binaryNum << endl;
system("pause");
}
Any ideas? Thanks for the help