Question

Write a program in c laungage that prints a table of the binary, octal and hexadecimal...

Write a program in c laungage that prints a table of the binary, octal and hexadecimal equivalents of the decimal numbers in the range1 through 256. Functions are not allowed and built-in functions for octa,binary and hexadecimal are also not allowed.

Homework Answers

Answer #1

Below is the c solution with output screenshot

Code :

#include<stdio.h>
void convert (int num, int base)
{
    int rem = num%base;
    if(num==0)
        return;
    convert(num/base, base);

    if(rem < 10)
        printf("%d", rem);
    else
        printf("%c", rem-10+'A' );
}

int main()
{
    printf("Decimal | Binary | Octal | Hexadecimal\n");
    for(int i=1;i<=256;i++){
        printf("%d | ", i);
        convert(i,2);
        printf(" | ");
        convert(i,8);
        printf(" | ");
        convert(i,16);
        printf("\n");
    }
    return 0;
}

Output :

...continued

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
2 Convert each of the following octal numbers to 10-bit binary, hexadecimal, and decimal. Show your...
2 Convert each of the following octal numbers to 10-bit binary, hexadecimal, and decimal. Show your work. (a) 368 (b) 7568 3 Convert the following binary values into Decimal, Octal and hexadecimal. Show your work. (a) 111010101011112 (b) 1010111011001102 (c) 1011101010001112 (d) 1111101011102 4 Convert the following hexadecimal numbers to 16-bit binary and decimal numbers. Show your work. (a) FE9816 (b) FCAD16 (c) B00C16 (d) FEDF16 5 Perform the addition on the following unsigned binary numbers. Indicate whether or not...
Convert each of the following decimal numbers to binary, octal, and hexadecimal numbers. Only go to...
Convert each of the following decimal numbers to binary, octal, and hexadecimal numbers. Only go to 7 bits to the right of the decimal and be sure to appropriately round the 7th bit. (f) 250.8
how can i convert an octal value 362.54 to decimal, binary, and hexadecimal?
how can i convert an octal value 362.54 to decimal, binary, and hexadecimal?
a) Decimal 345.625 to binary, octal, and hexadecimal. please show work, i am lost.
a) Decimal 345.625 to binary, octal, and hexadecimal. please show work, i am lost.
a) Decimal 345.625 to binary, octal, and hexadecimal. please show work, i am lost.
a) Decimal 345.625 to binary, octal, and hexadecimal. please show work, i am lost.
Write a program in Mars MIPS Assembly Language that asks the user for an 8-digit hexadecimal...
Write a program in Mars MIPS Assembly Language that asks the user for an 8-digit hexadecimal and then prints out its 32-bit binary representation, the operation of the function, the format (I, R, or J), the fields associated with the format (op, rs, rt, imm, shamt, funct), and the instruction associated with the hexadecimal. All five parts must be written as functions.
Convert each of the following decimal numbers to octal, hexadecimal, and decimal numbers using the most...
Convert each of the following decimal numbers to octal, hexadecimal, and decimal numbers using the most appropriate conversion method. (c) 0.375
In C++ 11, create a program does the following 4 conversions: From Binary to Decimal; From...
In C++ 11, create a program does the following 4 conversions: From Binary to Decimal; From Decimal to Binary; From Hexadecimal to Binary; From Binary to Hexadecimal; First create a menu so that user can choose which conversion they wanna do;
In C++ Write a program that will convert a string of binary digits to their decimal...
In C++ Write a program that will convert a string of binary digits to their decimal equivalent. For convenience limit the binary number to 16 bits. Write the decimal equivalent to the screen. For this program you must read in the binary number as a string type. If you were to enter a large binary number like 110110001100111 as a decimal value it would be too large to fit in an int type.
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal....
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal. 1. Request input data type. 2. Request input data. 3. Request output data type. 4. Output the data. The suggested approach was to take the input data as a string. But I am really lost as to how to process the string and then converting it to another data type. Thanks for the help!
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT