Vidyalelo
C++ Programming · Q549

C++ miscellaneous

Programming · C++ Programming · question 549

Q549

What will be the output of the following C++ code? #include #include "math.h" using namespace std; double MySqrt(double d) if (d < 0.0) throw "Cannot take sqrt of negative number"; return sqrt(d); int main() double d = 5; cout << MySqrt(d) << endl;

A.
5
B.
2.236
Answer
C.
Error
D.
Cannot take sqrt of negative number

Answer: Option B

Solution

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