Weird Code Issue
So I have a square root calculator in C++. It works great when I enter a number, gives accurate square roots, and so on. But when I don't enter a number into it, it says this: The square root of 2686816 is 1639.15 Why does it do this and how can I stop it? I don't know if this is relevant, but I am using #include <cmath> for my square roots. This is the full code: #include <iostream> #include <cmath> using namespace std; int main() { //Initializes 'user_input' int user_input; //Defines 'user_input' cin >> user_input; //Prints the square root of the user's input cout << "The square root of "; cout << user_input; cout << " is "; cout << sqrt(user_input) << endl; cout << "Thank you for viewing my project!" << endl; int Haha; Haha = sqrt(5*5*5*5) ; if (user_input == Haha) { cout << "Hey, your number," << user_input << ", is my alpha number!" ; } return 0; }