0

I'm trying to get someone to enter a number between -1 and 122. I want to use throw, catch and try if someone enters a char or string instead of a number. If that's the best way to do it?

#include <iostream>
using namespace std;

int main()
{
    int age;
    int x = 0;
    int y = 121;

    cout << "Enter you age: ";
    cin >> age;

    if (age >= x && age <= y)
    cout << "So your age is: " << age << ", that's believable";
    else
    cout << "Your age is " << age << "? Not Believable!";

    return 0;
}

0 Answers0