Linear equation solver

So I'm really new to C++ and decided to try to write a basic linear algebraic equation(y=ax+b) solver. I just get errors in the math section.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int a, b, y, z, t;

    cout << "This is a solver for linear algebraic equations. \nSo only equations that look like y=ax+b, will work.\n";
    cout << "Input the a variable.\n";
    cin >> a;
    cout << "Input the b variable.\n";
    cin >> b;
    cout << "Input the y variable.\n";
    cin >> y;

    y-b=z; //This is equal to ax=y-b, where you subtract the b from both sides. z=(y-b)
    z/a=t; //This is equal to x=(y-b)/a, where you divide both sides by a, leaving x by itself. t=(y-b)/a
    

    cout << "X=" << t;

}

Last edited on
The variable you want to assign the expression to needs to be on the left.

Such as
z = y-b;
Last edited on
Thank you! I forgot about that.
Topic archived. No new replies allowed.