Ruby program to get the magnitude of the given number

bookmark

num1 = Complex(2,3);
num2 = -15;
num3 = 3.14;

print num1.magnitude(),"\n";
print num2.magnitude(),"\n";
print num3.magnitude(),"\n";

 


Output:

3.605551275463989
15
3.14