Vidyalelo
C++ Programming · Q75

C++ miscellaneous

Programming · C++ Programming · question 75

Q75

What will be the output of the following C++ code? #include #include using namespace std; int main () int num = 3; string str_bad = "wrong number used"; try if ( num == 1 ) throw 5; if ( num == 2 ) throw 1.1f; if ( num != 1 || num != 2 ) throw str_bad; catch (int a) cout << "Exception is: " << a << endl; catch (float b) cout << "Exception is: " << b << endl; catch (...) cout << str_bad << endl; return 0;

A.
Exception is 5
B.
Exception is 1.1f
C.
Wrong number used
Answer
D.
Exception is 1.6g

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board