answersLogoWhite

0

The question is somewhat ambiguous. If you have a value stored in a c variable, you can output it as a hexadecimal value by using a %x specification (printf("%x",z); prints z as a hex value.

There is no specification (in most versions of c to input a binary number).

If you mean convert a string which looks like a binary number to a string which looks like a hexadecimal number, then here is a code fragment

char b[21]; // b holds binary string - 1 extra byte for null

char h[6]; // h holds hex string - 1 extra byte for null

char *p;

int s;

p=b;

s=0;

while (*p)

{

s = (s << 1) + (*p-'0');

p++;

}

sprintf(h,"%x",s);

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


Write a C program to convert hexadecimal number into decimal number?

pongada punda vayanungala ..................


A c program to convert decimal number to decimal number?

The question asks to do nothing by converting a decimal into itself. Perhaps the question was mistyped. Please restate the question.


How do you convert in to a decimal number?

The answer will depend on what you want to convert into a decimal number.


Write a Program to convert decimal number into hexadecimal no without using function and string?

This is not a question.


Write a c program to convert binary number to decimal number?

How is this a question? Sounds like you should do more of your homework offline.


How do you convert 3.27 in to a decimal number?

3.27 is already a decimal number.


Convert decimal number 12 into hexa decimal number?

It is C


How do you use a power of ten to convert a decimal to a decimal?

If the number is already in decimal form, you do not need to do anything to "convert" it to decimal!


How do you convert a fraction to a decimal and then percentage?

To convert a fraction to a decimal divide the numerator (top number) by the denominator (bottom number). To convert a decimal (or fraction) to a percentage multiply it by 100 %.


How do you divide a decimal by a mixed number?

Convert the mixed number to a decimal and proceed.


Explain how to compare a mixed number with a decimal?

Convert the mixed number to a decimal.