error: expected `;' before string constant

I keep getting these error messages:

piApproximator.cpp:30:13: warning: missing terminating " character
piApproximator.cpp:30: error: missing terminating " character
piApproximator.cpp:31:46: warning: missing terminating " character
piApproximator.cpp:31: error: missing terminating " character
piApproximator.cpp: In function ‘int main()’:
piApproximator.cpp:31: error: ‘expansion’ was not declared in this scope
piApproximator.cpp:31: error: expected unqualified-id before string constant
piApproximator.cpp:31: error: expected `;' before string constant

These are lines 29 and 31:
cout << "This program approximates pi using an n-term series expansion.";
cout << endl << "Enter the value of n>";
cin >> n;

I'm sure there is no extra " floating around. The program runs on, but when I try to run it on pico, these error messages pop up, and it fails. I have to run it on pico for school.

There is nothing wrong with those three lines.
Please post the entire code.

Be sure to use code tags (the <> formatting button) when posting code.
Last edited on
I get no errors when compiling with Visual Studio 2010.
u may have forgot "using namespace std;" its happened to me and i've gotten a similar issue (think the same) once
Well, thanks. I have one other problem.

This is what approx is supposed to equal when I enter n as 6.
This is what I get:

There seems to be a precision problem, but I don't know if it is my compiler (or the compiler my teacher used) or something in the code I left out.
Last edited on
It could be compiler, it could be processor floating point issues.
Your result seems OK to 15 significant figures, which is about all you are going to get from a double.

Normally 15 s.f. is good enough for most things.

In terms of error in the code, are you sure you haven't missed the last term or something?

Topic archived. No new replies allowed.