Answer to Question #278812 in C++ for Zaifi

Question #278812

Write a c++ program to receive integer number and convert equivalent to binary, octal, hexadecimal number

1
Expert's answer
2021-12-12T20:21:33-0500
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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog