mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
commit
30b1ece5a1
21
conversions/binary2hexa.c
Normal file
21
conversions/binary2hexa.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user