How do I get my code to print “Invalid input” when I enter for example a character? when I enter a character my output is “The number is 0”.
int main() {
int number;
cout << "Enter an integer: ";
cin >> number;
if (number > 0)
cout << number << " is a positive integer";
else if (number < 0)
cout << number << " is a negative integer";
else if (number == 0)
cout << "The number is 0";
else
cout << "Invalid input";
return 0;
}