pascal - Arithmetic Operation on a string -


i have task in school extraculicular. task create calculator can run 1 input. example, input: 3+7+1*2

and output 12

like that, how create that? have search in google create calculator of them show basic tutorial "input first number:" "input second number" "what operator u want" "result"

thank's before. english not well.

that easy in free pascal:

uses symbolic;  var s : string; begin   s:='3+7+1*2';   //readln(s)   writeln(round(quickevaluate(s,[],[]))); end. 

prints

 12 

you can read input expression user readln(s) instead of fixed expression.

the round because evaluation returns single, more details see sources of unit symbolic.


Comments