-
What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
double Option1 = 12, Option2 = 6, Result;
char Option;
try
{
if (Option != '+' && Option != '-' && Option != '*' && Option != '/')
throw Option;
switch(Option)
{
case '+':
Result = Option1 + Option2;
break;
case '-':
Result = Option1 - Option2;
break;
case '*':
Result = Option1 * Option2;
break;
case '/':
Result = Option1 / Option2;
break;
}
cout << "\n" << Option1 << " " << Option << " "<< Option2 << " = " << Result;
}
catch (const char ch)
{
cout << ch << "Is not a valid Option...";
}
return 0;
}
-
- Compilation Error
- Runtime Error
- Garbage Value
- Is not a valid Option...
- None of these
Correct Option: D
It will arise a exception because we missed a operator.