Adding variables with equations

hi, i'm trying to receive this equations in the output with the sum:
The sum of
3a+9b+10c-8d=6
9a-2b+3c-4d=4
12a+7b+13c-12d=10
i would appreciate any suggestions how to correct the syntax errors to compile the program.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <iomanip>
using namespace std;

int main() 
{ 
	int x;
	x[]={int a, b, c, d, e};
	int sum;
	int a = (3+9), b = (9+2), c = (10+3), d = (-8-4), e = (6+4);
    sum = [a],[b],[c],[d],[e];

	cout <<"The sum of "<<endl; 
	cout <<"3a+9b+10c-8d=6 "<<endl;
	cout <<"9a-2b+3c-4d=4 "<<endl;
	cout <<[a]<<"a"<<[b]<<"b"<<[c]<<"c"<<[d]<<"d"<<"="<<[e]<< endl; 
 
    return 0; 
}

1
2
3
4
5
6
7
8
9
10
11
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(8) : error C2059: syntax error : ']'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(8) : error C2143: syntax error : missing ';' before '{'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(8) : error C2143: syntax error : missing ';' before '}'
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(11) : error C2059: syntax error : '['
1>c:\users\martin\documents\visual studio 2008\projects\week\week\week.cpp(16) : error C2059: syntax error : '['
1>Build log was saved at "file://c:\Users\Martin\Documents\Visual Studio 2008\Projects\week\week\Debug\BuildLog.htm"
1>week - 5 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

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

And the []s in your cout are redundant.

-Albatross
Thank you i rewrote it and got it to compile but realize this was not the instructions given by the professor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <iomanip>
using namespace std;

int main() 
{ 
	
	int sum;
    int a = (3+9), b = (9+2), c = (10+3), d = (-8-4), e = (6+4);
    sum = a,b,c,d,e;

	cout <<"The sum of "<<endl; 
	cout <<"3a+9b+10c-8d=6 "<<endl;
	cout <<"9a-2b+3c-4d=4 "<<endl;
	cout <<a<<"a"<<"+"<<b<<"b"<<"+"<<c<<"c"<<d<<"d"<<"="<<e<< endl; 
 
    return 0; 
}
Why have you opened so many topics about the same stuff?

 
sum = a + b + c + d + e;
What is sum supposed to be for?
And why don't you just output "12a+7b+13c-12d=10" directly?
What you're trying to do would make sense if the user could specify two arbitrary equations, but that is not the case. The result is already known beforehand and your current code cannot be used in a generic way anyway.
Topic archived. No new replies allowed.