saintj0n has asked for the wisdom of the Perl Monks concerning the following question:
#!C:\Perl\ use warnings; use strict; #binary.plx print"Please enter an integer less than or equal to 256: "; our $decimal = <STDIN>; our @binary = ("0","1","2","3","4","5","6","7","8"); our $x = 0; print"Checkpoint1\n"; if ($decimal == "256") { print "In binary, that is "; while ($x < 8) { @binary[$x]=1; print @binary[$x]; $x++; } die"\n\nProgram ended successfully"; } elsif ($decimal < "256") { @binary[0] = 0; } # Nothing more needs to be done here. elsif ($decimal >"256") { die"\nYou entered an invalid number!\n\n"; } $decimal-=128; print"\ndecimal is ",$decimal; if ($decimal < "128") { @binary[1] = 0; print"\nThe second digit ",@binary[1]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: a newbie's output reversed
by johngg (Canon) on Dec 13, 2011 at 23:40 UTC | |
|
Re: a newbie's output reversed
by toolic (Bishop) on Dec 13, 2011 at 22:16 UTC | |
|
Re: a newbie's output reversed
by NetWallah (Canon) on Dec 14, 2011 at 01:08 UTC | |
|
Re: a newbie's output reversed
by Anonymous Monk on Dec 14, 2011 at 08:50 UTC | |
by Anonymous Monk on Dec 14, 2011 at 08:59 UTC |