Hey all I'm new C++ and am having a little trouble with a simple program. The program calculates the square root of a number the user inputs. When I input -1 or any negative it comes up as 1.#ind. Ideally when the user types -1 i want -1 to come up as the answer. I know this is not right but it is whats required. Thanks.
#include <iostream>
#include <cmath>
using namespace std;
double weirdSquareRoot(double input)
{
return sqrt(input);
}
int main()
{
double x, someNumber;
cout << "Enter a number (a double): ";
cin >> x;
someNumber = weirdSquareRoot(x);
cout << "The square root is " << someNumber << endl;