Im in between C++ classes, so to keep practice I wrote a program to find roots.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double input;
bool done = false;
static double check;
while (done == false)
{
cout << "what number to root? ";
cin >> input;
bool foundRoot = false;
check = input;
while (foundRoot == false)
{
if (check * check == input || check*check < input)
{
foundRoot = true;
//done = true;
}
else
{
check = check - .00001;
}
}
cout << "The root of " << input << " is " << setprecision(7) << check << endl;
}
}
This program seems to return the correct values for any square tested (even non-perfects); however entering "25" returns 4.9999~. Why?