Write a C program and use only the Standard C Library Functi

Write a C program (and use only the Standard C Library Functions) to print a table of the binary and hexadecimal equivalents of the decimal numbers in the range 0 through 1024

For Example:

Solution

#include <stdio.h>

void get_binary(i)
{
int rem,binary=0,j=1;

while ( i!= 0)
{
rem = i%2;
i = i/2;
binary = binary + (rem*j);
j = j*10;
}
printf(\"%d\\t\",binary);
}

void get_hex(i)
{
printf(\"%X\ \",i);
}

main()
{

int i;

printf(\"Decimal\\tBinary\\tHex\ \");

for (i=0;i<1024;i++)
{
printf(\"%d\\t\",i);
get_binary(i);
get_hex(i);

}

}

Write a C program (and use only the Standard C Library Functions) to print a table of the binary and hexadecimal equivalents of the decimal numbers in the range

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site