Thread: Formulas

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    4

    Formulas

    hay.. I'm kinda new.. well... really new.. to C++. I'm wondering if theres any way for a user to input an equation. i'm working on a program that had embedded equations, the only problem is I want the user to be able to define the equations to fit their own need. i've been trying different approaches, but I can't find anything anywhere that hints on how to do this, short of strings of IF statements or strings of switches... can anyone help?

  2. #2
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Yup, you have to parse it yourself, unless you can compile on the fly. I made a graphing program a long time ago, and you had to change the source code to get it to draw another equation, since I didn't know the solution back then (I was using BASIC). However, the problem arose on the DevShed board a few weeks ago, and after thinking about the problem newly (after about 10 years), I came up with a solution using pointers to functions, which I am going to implement myself, soon. If you are a newbie at C++, then you may wish to pass on this. But, here's the thread, if you want to look at my answer:dynamically defined functions I think it will work.

  3. #3
    Student Forever! bookworm's Avatar
    Join Date
    Apr 2003
    Posts
    132
    Yes,functions r the easiest way to solve operations.From simple BODMAS operations to long equations, functions r the answer.If u dont know much of OOP,make the user enter 1 value at a time and print the final answer in the end.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Understanding formulas, shapes, algorithms etc
    By hardi in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 04-16-2007, 01:23 PM
  2. recursive formulas with arrays
    By Alastor in forum C Programming
    Replies: 4
    Last Post: 10-14-2005, 07:08 PM
  3. Formulas, resources for DirectX?
    By Skynet-systems in forum Game Programming
    Replies: 5
    Last Post: 01-22-2005, 07:56 PM
  4. "Patenting" math formulas or something like that
    By deltabird in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 02-26-2003, 04:47 AM
  5. formulas & edit boxes, c++ on MSVC++ 5
    By TravelByMail in forum Windows Programming
    Replies: 1
    Last Post: 03-09-2002, 12:45 AM