Computer Applications

Write a program to print:

i. x to the power y

ii. the square root of y

The values of x and y are 81 and 3, respectively.

Java

Java Math Lib Methods

16 Likes

Answer

public class KboatNumber
{
    public static void main(String args[]) {
        int x = 81;
        int y = 3;
        
        double r1 = Math.pow(x, y);
        System.out.println("x to the power of y = " + r1);
        
        double r2 = Math.sqrt(y);
        System.out.println("Square root of y = " + r2);
    }
}

Output

Answered By

9 Likes


Related Questions