Computer Applications

Write a program to print:

i. p to the power q
ii. the square root of p

The values of p and q are 64 and 2 respectively.

Java

Java Math Lib Methods

54 Likes

Answer

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

Output

Answered By

26 Likes


Related Questions