Dremendo Tag Line

Input 2 integers and print the square root of the power of the numbers using mathematical functions in Java

Mathematical Functions - Question 6

In this question, we will see how to input 2 integer numbers and print the square root of the power of the numbers ab in Java programming using the mathematical functions. To know more about mathematical functions click on the mathematical functions lesson.

Q6) Write a program in Java to input 2 integer numbers and print the square root of the power of the numbers ab.

Program

import java.util.Scanner;

public class Q6
{
    public static void main(String args[])
    {
        float a,b;
        double p,sr;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter 2 integer numbers");
        a=sc.nextInt();
        b=sc.nextInt();
        p=Math.pow(a,b);
        sr=Math.sqrt(p);
        System.out.println("Square root of power " + p + " = " + sr);

    }
}

Output

Enter 2 integer numbers
3
2
Square root of power 9.0 = 3.0
video-poster