Felanpro

Small Number Square Root Calculator

Apr 20th, 2019
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 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_ = .01;
  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 + .05 >= input && result <= input)
  25.             {
  26.                 gettingResult = true;
  27.             }
  28.  
  29.             iterator_ += .01;
  30.         }
  31.  
  32.         cout << "Square root of " << input << " = " << iterator_ << endl;
  33.         iterator_ = .01;
  34.         system("cls");
  35.     }
  36.  
  37.     int pause; cin >> pause;
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment