error C2447

Could someone please look at this program and tell me why it says error C2447?

#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>

using namespace std;

double taylor(double x);

int main()
double x,n,i;
cout<<"Sum er "<<i<<"";
return 0;
double taylor(double x);
double sum;
int k,t,g;


for (k=1;k<=n;k=k+1)

return j;
Last edited on
It says error C2447: '{' : missing function header (old-style formal list?).
I am using visual studio 2010.
return 0;
double taylor(double x);

You need to remove the ; in your function definition.
Last edited on
You haven't declared j. And you have ; in the declaration of your function.

You used unneeded libraries and used unneeded variables and if you used += and ++ operators your code would be shorter. Make sure that changes.
Last edited on
thanks a lot to both of you.
zoran404 (86), what do you mean by:
"if you used += and ++ operators your code would be shorter." What do you mean? How?
@zoran404: It doesn't make such a big difference in built-in types.

Anyways, to the explanation:


This uses the '+' operator.

Because of this reason:

a = a + b;

To use the += operator, you should:

a += b;

But I think for built-in types, this is performed automatically by the compiler via optimizations.

Same for t = t+3, it can become t += 3.
And for g=g+1 it can become g++ or ++g.

Don't refer to errors like on the topic's title.
We don't remember their meaning on the fly.
Luckily you wrote another post where you wrote the actual message of the error (Which is what we can understand on the fly, and will allow us to help you)

Also make good use of the Edit button, you posted two replies to the same thread within two minutes, which doesn't really look so good, and you could have edited the first post... I guess, unless Twicker edited the system.

But seeing you only made 6 posts that's almost good.

Also, when you put some code in your posts, write
and put your code in the middle.

[code]char c = 'x';[/code]
becomes char c = 'x';
And tabbing is preserved too within the so called code tags.
Last edited on
Topic archived. No new replies allowed.