Advertisement
Felanpro

super accurate square root calc

Apr 22nd, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include "USEFUL_FUNCTIONS.h"
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     float input;
  10.     float result;
  11.     bool gettingResult = false;
  12.     bool console_still_going = true;
  13.     float iterator_ = .00001;
  14.  
  15.     while (console_still_going)
  16.     {
  17.         cout << "Insert the number you want to get the square root of: " << endl;
  18.         cin >> input;
  19.  
  20.         while (!gettingResult)
  21.         {
  22.             result = iterator_ * iterator_;
  23.  
  24.             if (result > input)
  25.             {
  26.                 gettingResult = true;
  27.             }
  28.  
  29.             cout << iterator_ << endl;
  30.             iterator_ += .01;
  31.         }
  32.  
  33.         cout << "Square root of " << input << " = " << iterator_ << endl;
  34.         iterator_ = .01;
  35.         gettingResult = false;
  36.     }
  37.  
  38.     int pause; cin >> pause;
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement