added binary to hexadecimal conversion

This commit is contained in:
DEBASISH SAHOO 2018-01-28 18:45:09 +05:30 committed by GitHub
parent 2d376fb740
commit 264fd91af9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

21
conversions/binary2hexa.c Normal file
View File

@ -0,0 +1,21 @@
/*
* C Program to Convert Binary to Hexadecimal
*/
#include <stdio.h>
int main()
{
long int binary, hexa = 0, i = 1, remainder;
printf("Enter the binary number: ");
scanf("%ld", &binary);
while (binary != 0)
{
remainder = binary % 10;
hexa = hexa + remainder * i;
i = i * 2;
binary = binary / 10;
}
printf("THe Equivalent hexadecimal value: %lX", hexa);
return 0;
}