In this HackerRank Cpp exception handling problem in c++ we need to debug the pre-written code. so that it can successfully print the invalid exception.

HackerRank Cpp exception handling in C++ problem solution


HackerRank Cpp exception handling in C++ problem solution

void process_input(int n) {
    try {
        int d = largest_proper_divisor(n);
        cout << "result=" << d << endl;
    } catch (const invalid_argument& e) {
        cout << e.what() << endl;
    }
    cout << "returning control flow to caller" << endl;
}