Hi all, i need one help from u.when u give expression like 10+4*2-6/8 the expression should be evaluated in hierarchy order and the result will be displayed. the expression may be any longer or shorter.the operands used are +,-,*,/,mod, pow..please any one help in writing coding on this...
Parser program
Collapse
X
-
Tags: None
-
I'm not sure what you are asking for; please elaborate on your problem, and ask a question.Originally posted by anandaramanHi all, i need one help from u.when u give expression like 10+4*2-6/8 the expression should be evaluated in hierarchy order and the result will be displayed. the expression may be any longer or shorter.the operands used are +,-,*,/,mod, pow..please any one help in writing coding on this... -
In any computer language, to force the order of precedence of calculations use brackets () as these have the highest order of precedence in computers and mathematicsComment
-
i know, there ia already predefined function that calculate the expression, but i need the program that perform the calculationComment
-
If you know, why are you asking us? And what are you asking for? A PHP predefined function or a user defined function? Both seem pointless and inefficient because it can be done using basic mathematicsi know, there ia already predefined function that calculate the expression, but i need the program that perform the calculationComment
-
What you are asking is to write an interpreter written in an interpreter language, i.e. PHP. That is not a good idea. If you want to develop such an interpreter you should use a compiled language, like C.
Or is this just an exercide for a class assignment?
Ronald :cool:Comment
-
10+4*2-6/8
here evaluation order will be
step1-- 4*2
step2-- 6/8
step3-- 10+step1
step4--step3-step2
so accordingly arrange your variables...... ...Comment
Comment