I have an addition to problem with HELP!!!
Quote:
Originally posted by maes
>> cout << '\" << i << '\" << " = " << i;
I don't really understand why you are using '\'
If it is just for layout you have to use '\\'
you can't mix ' and "
Change this line with :
cout << '\\' << i << '\\' << " = " << i;
and it should work.
bye
#include <iostream.h>
void to_binary(int i);
int main()
{
int i;
{
cout << "Enter a number:" << endl;
cin >> i ;
dec(cout); // Set output to decimal
cout << '\\' << i << '\\' << " = " << i;
oct(cout); // Set output to octal
cout << " = 0" << i;
hex(cout); // Set output to hex
cout << " = 0x" << i << '\n';
//bin(cout); // Set output to binary
//cout << " = 0" << i << '\n';
}
return 0;
}
{
void to_binary(int n) //recursive function
}
{
int r;
r = n % 2;
if (n >= 2)
to_binary(n / 2);
putchar('0' + r);
return;
}