This works is the square root is a whole number (25 for example), but how can I do a function that works with any number?Code:int sqrt(int root) { int i = 0; bool done = false; while(!done) { i++; if ((i*i) == root) done = true; else if (i == root) { cout<<"No whole root"; done = true; } } return i; }




Reply With Quote