Hello everyone. I'm working on a project but I've gotten stuck. First off I'm working in FreePascal (ver 2.6.4). I need to make a program capable of converting a number of any base 2 to 16 to decimal. My problem however is that I can't use things like array/string/readkey/type, etc. Basically I can only use the functions repeat/while/for/if/case/read(ln)/write(ln). As for types, only integer/real/boolean/char.. My problem arises from how I need to input the variable. It needs to be:
>base:number.
>answer in base 10
For example
>16:123.
>291
Note how the entire number is written in one line, and how "base" and "number" are separated by a ":". I can't really get that to work.
Another thing is my use of Horner's Rule, which is:
result = 1stNumber + (result*base) - in this case result = 0 since there was no prior input.
result = 2ndNumber + (result*base)
result = 3rdNumber + (result*base)
...etc
Replacing the numbers with "123":
result = 1
result = 2 + (1*16)
result = 3 + (18*16)
result = 291
But I can't seem to separate the input to do so, least not without array. I know I should technically be able to read the input numbers and analyze them one by one, converting them from char to integer by using Ord, but I'm not sure how to do it.
I'm rather new at this so any help is highly appreciated.