adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include<iostream>
    #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

c.

Error

d.

Cannot take sqrt of negative number

Answer: (b).2.236

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?