Computer Applications

Predict the output :

class Test {
    public static void main (String args[]) { 
        double x, y, z ;
        x = 3;
        y = 4;
        z = Math.sqrt(x * x + y * y); 
        System.out.println("z = " + z);
    }
}

Java

Java Math Lib Methods

6 Likes

Answer

z = 5.0

Working

z = Math.sqrt(x * x + y * y)
  ⇒ Math.sqrt(3.0 * 3.0 + 4.0 * 4.0)
  ⇒ Math.sqrt(9.0 + 16.0)
  ⇒ Math.sqrt(25.0)
  ⇒ 5.0

Answered By

3 Likes


Related Questions