program Hello; uses Crt, Math, Sysutils, StrUtils, System; Function pwr(x: Real; y: Real): Real; Var rs: Real; Begin rs := 1; while(y > 0) do Begin rs := rs * x; y := y - 1; End; pwr := rs End; Function BinToDec(binary: String): Real; Var i, pw: Integer; dec: Real; Begin dec := 0; pw := 0; for i:= length(binary) downto 1 do begin dec := dec + ((pwr(2, pw)) * StrToInt(binary[i])); Inc(pw); End; BinToDec := dec; End; var binary, secret: String; i: Integer; dec: Real; pw: Integer; secrets: array of AnsiString; begin writeln ('Awesome binary converter'); binary := '10110100'; secret := '01010100 00100111 01100101 01110011 00100000 01100011 01110101 01110010 01101001 01100101 01110101 01111000 00100000 01110100 01101111 01101001 00100000 00111010 00101001'; pw := 0; //Writeln(pwr(2, 5):0:2); //exit(); secrets := strutils.SplitString(secret, ' '); Writeln('length = ', length(secrets)); dec := BinToDec(binary); Writeln(dec:0:0); end.
Write, Run & Share Pascal code online using OneCompiler's Pascal online compiler for free. It's one of the robust, feature-rich online compilers for Pascal language. Getting started with the OneCompiler's Pascal editor is easy and fast. The editor shows sample boilerplate code when you choose language as Pascal and start coding.