Q474
What will be the output of the following C++ code? #include #include using namespace std; int main() double Op1 = 10, Op2 = 5, Res; char Op; try if (Op != '+' && Op != '-' && Op != '*' && Op != '/') throw Op; switch(Op) case '+': Res = Op1 + Op2; break; case '-': Res = Op1 - Op2; break; case '*': Res = Op1 * Op2; break; case '/': Res = Op1 / Op2; break; cout << " " << Op1 << " " << Op << " "<< Op2 << " = " << Res; catch (const char n) cout << n << " is not a valid operator"; return 0;
A.
15
B.
5
C.
2
D.
is not a valid operator
AnswerAnswer: Option D
Solution
Answer: Option D
No explanation is given for this question Let's Discuss on Board