What will happen when the handler is not found for exception?
What is the output of this program?
1. #include2. #include 3. using namespace std; 4. int main() 5. { 6. try { 7. int * array1 = new int[100000000]; 8. int * array2 = new int[100000000]; 9. int * array3 = new int[100000000]; 10. int * array4 = new int[100000000]; 11. cout << "Allocated successfully"; 12. } 13. catch(bad_alloc&) { 14. cout << "Error allocating the requested memory." << endl; 15. } 16. return 0; 17. }
What is the output of this program?
1. #include2. using namespace std; 3. void Funct(); 4. int main() 5. { 6. try { 7. Funct(); 8. } 9. catch(double) { 10. cerr << "caught a double type..." << endl; 11. } 12. return 0; 13. } 14. void Funct() 15. { 16. throw 3; 17. }
What is the output of this program?
1. #include2. using namespace std; 3. int main() 4. { 5. char* buff; 6. try { 7. buff = new char[1024]; 8. if (buff == 0) 9. throw "Memory allocation failure!"; 10. else 11. cout << sizeof(buff) << "Byte successfully allocated!"<
What is the output of this program?
1. #include2. using namespace std; 3. double division(int a, int b) 4. { 5. if (b == 0) { 6. throw "Division by zero condition!"; 7. } 8. return (a / b); 9. } 10. int main () 11. { 12. int x = 50; 13. int y = 2; 14. double z = 0; 15. try { 16. z = division(x, y); 17. cout << z; 18. } 19. catch(const char *msg) { 20. cerr << msg; 21. } 22. return 0; 23. }