Write a c++ program to receive integer number and convert equivalent to binary, octal, hexadecimal number
void intToBinary(int n)
{
int binary[32];
int i = 0;
while (n > 0) {
binary[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--)
cout << binary[j];
}
void intToHex(int n) {
char hex_num[20];
sprintf(hex_num, "%X", n);
cout << hex_num;
}
Comments
Leave a comment