Newton Raphson's Method C language program - To find Square Root


Posted Date:     Total Responses: 0    Posted By: rajesh kale   Member Level: Silver   Points/Cash: 4   


C Language Program - Newton Raphson's Method : To find Square Root



#include
#include
#include
float f(float x,int n)
{
return(x*x-n);
}
float df(float x)
{
return 2*x;
}
void main()
{
float b=5,m,e=0.0001,num;
int i;
clrscr();
printf("\n Newton Raphson's Method : To find Square Root");
printf("\n Enter Number whose Square root to be found :- \n");
scanf("%f",&num);
m=(b)-((f(b,num))/df(b));
i=1;
while(fabs(f(m,num))>e)
{
b=m;
m=(b)-((f(b,num))/df(b));
i=i+1;
printf("\n Square root of %.2f is %.2f",num,m);
getch();
}
}



Project Feedbacks

Author: Member Level: BronzeRevenue Score: 5 out of 55 out of 55 out of 55 out of 55 out of 5

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

float f(float x,int n)
{
return(x*x-n);
}

float df(float x)
{
return 2*x;
}

void main()
{
float b=5,m,e=0.0001,num;
int i;
clrscr();
printf("\n Newton Raphson's Method : To find Square Root");

printf("\n Enter Number whose Square root to be found :- \n");
scanf("%f",&num);
m=(b)-((f(b,num))/df(b));
i=1;
while(fabs(f(m,num))>e)
{
b=m;
m=(b)-((f(b,num))/df(b));
i=i+1;
printf("\n Square root of %.2f is %.2f",num,m);
getch();
}
}


OUtput


Newton Raphson's Method : To find Square Root
Enter Number whose Square root to be found :-
7

Square root of 7.00 is 2.69
Square root of 7.00 is 2.65
Square root of 7.00 is 2.65




Post Feedback
You must Sign In to post a feedback.
Next Project: Newton Raphson method To find Cube Root C Language Program
Previous Project: Implementation of Circular Queue using Array

Return to Project Index

Post New Project


Related Projects


Complete the action items below to enter to win an iPad Mini from India Study Channel! in India Study Channel - Locker on LockerDome
Awards & Gifts
Active Members
TodayLast 7 Daysmore...

 
ISC Technologies, Kochi - India. © All Rights Reserved.




Click the "Follow" button above to follow Tony John