error list- simple math computation

Hello

I just started a c++ class. I have no experience with programming so bear with me.
I've come across a few errors, which i can't understand why.


Here's my program so far:

--------------------------------------------------------------------------

#include <iostream> // missing ';' before '}' also says this is line 29
using namespace std;

int main ()
{
double n, answer;

n = 6;

answer = 3+4+5+n;
cout <<"3+4+5+"<<n<<"="<<answer<<endl<<endl;

answer = (n * (n+1) / 2) - 3;
cout <<"("<<n<<"*"<<"("<<n<<"+"
<<"1"<<")"<<"/"<<"2"<<")"
<<"-"<<"3"<<"="<<answer<<endl<<endl;

answer = 1+3+5+7+9+(2n - 1); //missing ')' before identifier 'n'
cout <<"1+3+5+...+"<<"("<<"2"<<"*"<<"6"<<"-"<<"1"<<")"
<<answer<<endl<<endl;

answer = n * n;
cout <<"n"<<"*"<<"n"<<answer<<endl<endl; //missing ',' before ';'


return 0;

} // line 28, missing ';" before '}' , missing '>' before '}'

------------------------------------------------------------------------

also it says on the first line which it reads as line 29
Error 8 fatal error C1004: unexpected end-of-file found c


I did this program following examples of similar ones in class, and the teacher hasn't shown any use or examples of needing to input these various things that the error lists states. If anyone could help me out, I'd definitely appreciate it. thanks
This
 
answer = 1+3+5+7+9+(2n - 1); 

Should be this
 
answer = 1+3+5+7+9+(2*n - 1); 


I don't know if there are other errors, I didn't notice anything.
Topic archived. No new replies allowed.