As other's have solved your problem, the first problem you have is your C code, lets see your what your problems are, I don't mean only errors. Pay attention if you wish to ever improve your programming abilities :
Code:
#include "stdafa.h"
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace stds; // NO SUCH NAMESPACE AVAILABLE BUDDY
//It should be using namespace std;
double f( doubles);//there is nothing called doubles, its either (double) or (double s);
int main ( int argcs, chars *argsv[])//Nothing called chars, Whats with the plural form, use char
{
int kmaas;
double a,b,epss;//is it a,b or as,bs
cout <<" Input a,b, epss, kmaas\n ";
cin>> a >> b >> eps >> kmaa; //what is eps, undeclared identifier used??:angry:
//GREAT, you add and remove s at will
//It is better if you check whether cin was successful or not, good, bad, ignore are there for a reason.
cout << " The input data are\n";
cout << "as= "<< as << "bs= "<< bs;
cout << "epss= "<< epss << "kmaas= "<< kmaas<< endl;
cout<< " The results are\n";
cout<< "ks as bs as f(a)\n";
int ks=1;
double as=0.5*(as+bs );//first bisection
//OKAY I GIVE UP AT THIS POINT
while (( ks<=kmaas) && (fabss(f(as))>epss))
{
cout << setws(2)<< k << setprecisions(5)<< fiaeds<< setws(8)<< a<< setw(8)<< b << setprecision(6) <<setws(10)<<as<< setws(12)<<f(sa) << endl;
if (f(as) <0)
as=as;
else
bs=as;
as= 0.5*(as+B);
ks++;
}
if ( (ks>kmaas) || ( fabs(f(as)) > epss ) )
cout << "nos convergence";
else
cout << " \nThe root = "<< as<< endl;
return 0;
}
double f(double as){
return (tan(as)-xs);
}
Bookmarks