error: expected ',' or ';' before 'int'

i'm new to c++. need help.
i got this error...

error: expected ',' or ';' before 'int'
error: 'n' was not declared in this scope
error: 'i' is not declared in this scope
error: 'tabs' was not declared in this scope
error: expected ';' before 'i'
error: expected ';' before string constant

AND this is my code:

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <conio.h>

using namespace std;

int main ()
{

double f,f2,d0,d,error,e;
double k1=50000,k2=40,m=90,g=9.81,h=0.45
int i,n;

cout<<endl<<"What is your initial guess?"<<endl;
cin>>d;

cout<<endl<<"What is your maximum iteration?"<<endl;
cin>>error;

e=1.0;
cout<<endl<<"i"<<"di "<<"%"<<endl;

for (i=0;i<n;i++)
{

if (e>error)
{
d0=d;

f=(2.0/5.0)*k2*(pow(d0,5.0/2.0))+(1.0/2.0)*k1*(pow(d0,2.0))-m*g*d0-m*g*h;

f2=k2*(pow(d0,3.0/2.0))+k1*d0-m*g;

d=d0-(f/f2);

e=tabs(((d-d0/d)*100))i
cout<<i<<"i "<<d0" "<<e<<endl;
}

else
{
break;
}

}

cout<<endl"d=di-f(di)/f'(di)"<<endl;
cout<<endl<<"d="<<d0<<"-"<<f<<"/"<<f2<<endl;
cout<<endl<<"thus, the final answer is d= "<<d;

getch();
return 0;

}

can anyone help me? thanks!
This line:
 
double k1=50000,k2=40,m=90,g=9.81,h=0.45

should have a terminator at the end:
 
double k1=50000,k2=40,m=90,g=9.81,h=0.45;


There's no tabs() function. Did you mean abs()? There's also a terminator missing from the line of that function call.

This line:
 
cout<<i<<"i "<<d0" "<<e<<endl;

needs fixing a bit. Namely around the d section.
Last edited on
thanks alot
but i still got this problem

error: expected ';' before 'i'
error: expected ';' before string constant

how to fix these?
i'm sorry, it labs(), thanks for your help
The i at the end of the abs bit. If you're trying to multiply by i it should be *i.

The string, I reckon is because
 
cout<<endl"d=di-f(di)/f'(di)"<<endl;

should read more like:
 
cout << endl << "d=di-f(di)/f'(di)" << endl;
thanks :)
Topic archived. No new replies allowed.