URGENT help PASCAL

liunx

Guest
i wrote my codes but my prob is:<br />1. when u read a binary it start from the right, but 4 ME IT START FROM THE LEFT<br /> EXAMPLE: 110 = 6<br /> FOR ME THE ANS IS 3<br /> SO HELP PLZZ<br />2. a code to validate<br /> if some1 enter 1002 as binary disply error<br />hope i got help<br /><br />here's my code plz add the validation code and correct the first prob<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->program BinToDec;<br /><br />uses wincrt;<br /><br />Var<br />   Binary:string;<br />   Len:integer;<br />   base:integer;<br />   counter:integer;<br />   Result:integer;<br /><br />Begin<br />     writeln('Enter a binary number: ');<br />     Readln(Binary);<br />     Len:= Length(binary);<br />     Base:=1;<br />     Result:=0;<br />     For counter:=1 to Len do<br />         begin;<br />               if (Binary[counter]='1') then<br />                  result:= result+ base;<br />                  base:=base*2;<br />         end;<br /><br />     writeln(result);<br />end.<!--c2--></div><!--ec2-->
</div>
 
Top