declaring equations and variables.

Hi, i'm trying to write a program that adds equations with variables for example,

3a+9b+10c-8d=6
9a-2b+3c-4d=4

After reading text books and searching on the web i still don't know how to declare the equations with variables like 3a, 9a, 9b, 2b, 10c, 3c, 8d, 4d ,6, 4 to get started. I tried using int, char, double, with the equations with variables it doesn't work. Any feedback is very appreciated.
example program and the syntax error I receive:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 #include <iostream>
#include <iomanip>
using namespace std;

int main() 

{
	int x; int y;
	x=3a,9b,10c,8d;
	y=9a,2b,3c,4d;
        
	
        cout << "The sum of " << "x=" << x
             << endl; 
	
        return 0; 
}

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
27
28
29
30
1
1>Deleting intermediate and output files for project 'week', configuration 'Debug|Win32'
1>Compiling...
1>week.cpp
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2059: syntax error : 'bad suffix on number'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2146: syntax error : missing ';' before identifier 'a'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2065: 'a' : undeclared identifier
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2059: syntax error : 'bad suffix on number'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2146: syntax error : missing ';' before identifier 'b'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2065: 'b' : undeclared identifier
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2059: syntax error : 'bad suffix on number'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2146: syntax error : missing ';' before identifier 'c'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2065: 'c' : undeclared identifier
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2059: syntax error : 'bad suffix on number'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2146: syntax error : missing ';' before identifier 'd'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(9) : error C2065: 'd' : undeclared identifier
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2059: syntax error : 'bad suffix on number'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2146: syntax error : missing ';' before identifier 'a'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2065: 'a' : undeclared identifier
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2059: syntax error : 'bad suffix on number'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2146: syntax error : missing ';' before identifier 'b'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2065: 'b' : undeclared identifier
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2059: syntax error : 'bad suffix on number'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2146: syntax error : missing ';' before identifier 'c'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2065: 'c' : undeclared identifier
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2059: syntax error : 'bad suffix on number'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2146: syntax error : missing ';' before identifier 'd'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(10) : error C2065: 'd' : undeclared identifier
1>Build log was saved at "file://c:\Users\Martin\Documents\Visual Studio 2008\Projects\week\week\Debug\BuildLog.htm"
1>week - 24 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
You declarations do not do what you think they do. I think you need to re-read how variables work and remember that multiplication must be specified with an *, not to mention you haven't even declared a, b, c, d, etc.
Best place for you to start:

http://www.cplusplus.com/doc/tutorial/

And how would you solve that in real life? what value has a ,b, c or d?
Last edited on
Seriously, check RedX's link. This code has too many errors in it.

Specifically, check the section on variables and operators.

-Albatross
Topic archived. No new replies allowed.