code to solve for variables

Hey,
So I was thinking in math class about an easier way to to solve equations like
4=2/9x etc. I already got the basics on how to work C++ out I just dont know how to input the math into it. thx guys
closed account (48T7M4Gy)
Maybe show us what you have so far?

If you are just solving for x one way is to just have a line in your program x = 4 * 9 / 2; You will need to take care with number types to avoid possibly unwanted truncation errors.

You could also solve the problem by numerical methods such as successive approximations but perhaps that just might be overkill here. :)
If you want to work with any arithmetic expression then make them as simple as possible before putting them into program logic that will help you get better and correct results.
Topic archived. No new replies allowed.