-
What is the output of this program?
#include <iostream>
#include <math.h>
using namespace std;
double Function(double n)
{
if (n < 0.0)
throw "Cannot take sqrt of negative number";
return sqrt(n);
}
int main()
{
double n = 16;
cout << Function(n) << endl;
}
-
- 0.0
- 16
- 4
- Compilation Error
- None of these
Correct Option: C
We are finding the square root of the number, if it is a positive number, it can manipulate, Otherwise it will arise a exception.