ISRO Computer Science (CSE) 2026 - Question 27

All ISRO Computer Science (CSE) papers | ISRO Computer Science (CSE) 2026

Topic: Programming in C++

What is the output of the following C++ program?
#include <iostream>
int main() {
try {
throw 20;
} catch (double e) {
std::cout << "double";
} catch (...) {
std::cout << "ellipsis";
}
return 0;
}

  • A. Program terminates abruptly
  • B. Compilation error
  • C. double
  • D. ellipsis

Answer: D. ellipsis

Explanation: The statement `throw 20;` throws an exception of type `int`. The first catch block `catch (double e)` specifically catches exceptions of type `double` and ignores `int` exceptions (C++ does not perform implicit type casting during exception matching). The `catch (...)` block is a universal catch-all handler that catches any thrown exception not caught previously, so it executes and prints "ellipsis".

| | All questions of ISRO Computer Science (CSE) 2026