C programmes for Physics Practical Exam Nuton Rapson Method

0

Category:

Nuton Rapson Method Programme 


#include
#include
void main()
{
int count=0;
float x0,xn,fx,dfx;
clrscr();
printf("Intial guess Value x0:\n");
scanf("%f",&x0);
label:
fx=pow(x0,5)+3*x0*x0-10;
dfx=5*pow(x0,4)+6*x0;
xn=x0-fx/dfx;
if (fabs(xn-x0)<0.0001)
printf("\n The final root is%f\n",xn);
else
{
x0=xn;
count=count+1;
if(count>100)
printf("\n solution does not converge\n");
else
goto label;
}
getch();
}

Comments (0)

Post a Comment

Copyright © 2009 virtualinfocom All rights reserved. Theme by Games. | animation Ani2Pix.