//bakhshali approximation for calculating square root /* S=number for which squareroot is reqd. N=nearest perfect square d=S-N*N; //difference P=d/(2*N) A=N+P; ans=A-(p*P)/(2*A) */ #include<stdio.h> #include<conio.h> void main(){ float S; float P,A,d,ans; int N; printf("Enter number whose sqrt is reqd:"); scanf("%f",&S); N=check_nearest_perfect_sqre(S); d=S-N*N; P=d/(2*N); A=N+P; ans=A-(P*P)/(2*A); printf("Squareroot of %f is %f",S,ans); getch(); int check_nearest_perfect_sqre(double square) { int i=0; while((i*i)<square) i++; return i; } }
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Qt_tVimFYFUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.