Hi RMGir!
I wrote this program and it gives a correct output.
But I have one thing undone: that to display the binary number based on this output.
Could you please let me know how?
# Program to convert Decimal no. to Binary using Bitwise and operator
print "Input a decimal number lesser than 256: ", "\n";
my $decimal;
$decimal = <STDIN>;
print "The decimal number AND 128 gives us: ", $decimal & 128, "\n";
print "The decimal number AND 64 gives us: ", $decimal & 64, "\n";
print "The decimal number AND 32 gives us: ", $decimal & 32, "\n";
print "The decimal number AND 16 gives us: ", $decimal & 16, "\n";
print "The decimal number AND 8 gives us: ", $decimal & 8, "\n";
print "The decimal number AND 4 gives us: ", $decimal & 4, "\n";
print "The decimal number AND 2 gives us: ", $decimal & 2, "\n\n";
print "The decimal number AND 1 gives us: ", $decimal & 1, "\n";