I thought instead of trying to over complicate everything I thought I would use simple math to find the square root without using the sqrt() function.I found an article to prove my idea would work. So what I did was use two nested loops and have them multiply till they came with the answer equal to what was inputted by the user, then use some more math to find the answer. I realise I still have a lot to do, but right now I'm trying to get this part of the program working before I work on the rest of the math required to make it work.
This is the article I'm fine tuning my idea.
So my question is I'm ,currently stuck on trying to find a way to break the nested loops once I find the two integers that equal the number inputted. I've tried everything I could think of and nothing works.
Could I please get a hint or a suggestion?
This is the program
#include <iostream> #include <math.h> // int main() { double input; double ans; std::cout << "Enter number" <<std::endl; std::cin >> input; for(int x = 0; x < 11; x++) { for(double z = 0.0; z < 11; z++) { ans = x * z; std::cout << x <<" * "<< z <<" = "<<ans <<std::endl; if(ans = x * z) break; } if() break; } }