#!/usr/bin/perl
print ("Enter a Binary number: ");
$bina_number = <STDIN>;
chop ($bina_number);
$tempo = oct("0b$bina_number");
$hexa_number = sprintf('%X', $tempo);
print ("\nThe Hexadecimal equivalent of the Binary number $bina_number is: ", $hexa_number);
print ("\n\n\n");
Execution
Enter a Binary number: 11111111
The Hexadecimal equivalent of the Binary number 11111111 is: FF
Enter a Binary number: 10111111
The Hexadecimal equivalent of the Binary number 10111111 is: BF
Enter a Binary number: 1111111111111111
The Hexadecimal equivalent of the Binary number 1111111111111111 is: FFFF
Enter a Binary number: 10111100
The Hexadecimal equivalent of the Binary number 10111100 is: BC
Enter a Binary number: 1110
The Hexadecimal equivalent of the Binary number 1110 is: E
No comments:
Post a Comment