I'm having some problems with this program , it hangs during operation :
Any advice please ?Code:#include<stdio.h> #include<math.h> int main(void) { // Calculates the square root of number using the newton's method float temp_root; int number; printf("Please Enter the number whose sqrt is to be found\n"); scanf("%d",&number); if (number<0) { printf("invalid number entered"); return 0; } temp_root=(number+1); // To ensure the next statement is true initially while (((temp_root*temp_root)>number)||((((temp_root)*(temp_root))-number)<0.001)) { temp_root=(1/2*(number+(2/number))); } printf("The square root of the number is %f",temp_root); }



LinkBack URL
About LinkBacks



