#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int i=0;
char binarynum[100], hexdec[100];
printf("Enter Hexadecimal Value : ");
scanf("%s",hexdec);
printf("\nEqual Binary value is : ");
while(hexdec[i])
{
switch(hexdec[i])
{
case '0' : printf("0000");
break;
case '1' : printf("0001");
break;
case '2' : printf("0010");
break;
case '3' : printf("0011");
break;
case '4' : printf("0100");
break;
case '5' : printf("0101");
break;
case '6' : printf("0110");
break;
case '7' : printf("0111");
break;
case '8' : printf("1000");
break;
case '9' : printf("1001");
break;
case 'A' : printf("1010");
break;
case 'B' : printf("1011");
break;
case 'C' : printf("1100");
break;
case 'D' : printf("1101");
break;
case 'E' : printf("1110");
break;
case 'F' : printf("1111");
break;
case 'a' : printf("1010");
break;
case 'b' : printf("1011");
break;
case 'c' : printf("1100");
break;
case 'd' : printf("1101");
break;
case 'e' : printf("1110");
break;
case 'f' : printf("1111");
break;
default : printf("\nInvalid hexadecimal digit %c",hexdec[i]);
}
i++;
}
getch();
}
Output
Enter Hexadecimal Value : AB1c
Equal Binary value is : 1010101100011100
Explanation:
Hexadecimal and Binary Values
Hex | Decimal | Binary |
---|---|---|
0 | 0 | 0000 |
1 | 1 | 0001 |
2 | 2 | 0010 |
3 | 3 | 0011 |
4 | 4 | 0100 |
5 | 5 | 0101 |
6 | 6 | 0110 |
7 | 7 | 0111 |
8 | 8 | 1000 |
9 | 9 | 1001 |
A | 10 | 1010 |
B | 11 | 1011 |
C | 12 | 1100 |
D | 13 | 1101 |
E | 14 | 1110 |
F | 15 | 1111 |
- We want to convert hexadecimal number AB1c to binary. For this we will replace each hexadecimal digit to binary values using the above table:
Hexadecimal Number: A B 1 c
Binary Values: (1010) (1011) (0001) (1100)
So (AB1c)16 = (1010101100011100)2
Related Tags
- 9 in hexadecimal,
- Accentur interview questions and answers,
- algorithm to convert binary number to decimal number,
- algorithm to convert decimal to hexadecimal,
- Applied Materials interview questions and answers,
- Asian Paints Ltd. interview questions and answers,
- binary to hexadecimal in c,
- Bosch India Software interview questions and answers,
- c program to convert decimal to hexadecimal using while loop,
- c program to convert hexadecimal to decimal,
- c program to convert hexadecimal to decimal and vice versa,
- c program to convert hexadecimal to octal,
- c program to find binary equivalent of a number,
- c++ program to convert hexadecimal to binary,
- Capgemini interview questions and answers,
- CASTING NETWORKS INDIA PVT LIMITED interview questions and answers,
- CGI Group Inc interview questions and answers,
- Chetu interview questions and answers,
- Ciena Corporation interview questions and answers,
- Collabera Technologies interview questions and answers,
- decimal to binary in c,
- decimal to hex,
- decimal to hexadecimal converter,
- decimal to hexadecimal in c,
- decimal to hexadecimal in c without using array,
- Dell International Services India Pvt Ltd interview questions and answers,
- DHFL Pramerica Life Insurance Company Ltd interview questions and answers,
- Elico HealthCare Services Ltd interview questions and answers,
- Flipkart interview questions and answers,
- HCL Technol interview questions and answers,
- hex a0 to decimal,
- hex calculator,
- hex string to binary c,
- hex to decimal,
- hex to decimal chart,
- hex to decimal converter,
- hex to decimal in embedded c,
- hexadecimal number system,
- hexadecimal to decimal convertehex to decimal,
- hexadecimal to octal converter,
- hexadecimal to word converter,
- IBM interview questions and answers,
- Indecomm Global Services interview questions and answers,
- Mavenir interview questions and answers,
- Mphasis interview questions and answers,
- NetApp interview questions and answers,
- Oracle Corporation interview questions and answers,
- PeopleStrong interview questions and answers,
- R Systems interview questions and answers,
- Raqmiyat Information Technologies Pvt Ltd interview questions and answers,
- Reliance Industries Ltd interview questions and answers,
- SAP Labs India Pvt Ltd interview questions and answers,
- simple c program to convert hexadecimal to binary,
- simple c program to convert hexadecimal to decimal,
- Tata AIA Life Insurance interview questions and answers,
- Tech Mahindr interview questions and answers,
- The Linde Group interview questions and answers,
- write a c program to convert hexadecimal number to binary number,
- zenqa interview questions and answers