-
What is the output of this program?
#include <stdexcept>
#include <limits>
#include <iostream>
using namespace std;
void Function(char ch)
{
if (ch < numeric_limits::max())
return invalid_argument;
}
int main()
{
try
{
Function(50);
}
catch(invalid_argument& excep)
{
cout << excep.what() << endl;
return -1;
}
return 0;
}
-
- Invalid argument
- 50
- Compilation Error
- Runtime Error
- None of these
Correct Option: C
We can’t return a statement by using the return keyword, So it is arising an error.
Compilation Error
In function 'void MyFunc(char)':
8:36: error: expected primary-expression before ';' token
8:36: error: return-statement with a value, in function returning 'void' [-fpermissive]
In function 'int main()':
14:23: warning: overflow in implicit constant conversion [-Woverflow]