[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

about formulas

Posted on 2002-05-18
5
Medium Priority
?
187 Views
Last Modified: 2010-04-02
Hi;
I'd like to know how to enter an "equation or formula"
as variable.
ex:2*(p^2)*l;
by making the prog asking me about this formula, and use it as function inside the prog.
another example:
When u give an equation to a "graph"program for drawing
I need the clear example for that.
thank you
0
Comment
Question by:Mustapha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 7018440
In scripting langiages, such as JavaScript or VBS, you caould simly call eval(s) where s is the string variable containing the equation.

Alas, C++ is a compiled langiage and there is no direct way to do this (sorry).  An indirect method would be to write some progeam code that examines the input and determines the various steps needed to do the calculations (parsing the equation).  This is a non-trival piece of coding.

Here's an example:
http://srd.yahoo.com/goo/%22Equation+parser%22+and+%22C%2b%2b%22/4/T=1021738348/F=c676cba64a1c6a937f3cbcb6ed77e21d/*http://compilers.iecc.com/comparch/article/96-04-026

Here's a good one, but written in Visual Basic:
http://www.vbweb.co.uk/show/216/

Another Indirect method would be to write a .JS file that used the eval() fn and saved its result to a text file.  You could execute that .JS file, then read the result file.

-- Dan
0
 
LVL 2

Expert Comment

by:Ixeus
ID: 7020912
You write what you call a parser, there are many parsers on the net, just search for  c++ formula parser,  this will analyze a string and calculate a return value of the formula you have.  Yes what was said was right, C++ is compiled code, no intermediate code.

-Ixeus
0
 
LVL 4

Expert Comment

by:havman56
ID: 7020999
Dan
 really nice to see the link u had given for c++.
me too intrested in it!

0
 
LVL 11

Expert Comment

by:griessh
ID: 7178802
Dear Mustapha

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "DanRollins"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/


PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7199803
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question