Java program to find power of a number

Java program to find power of a number

Java program to find square of a number

Java program to find cube of a number

Java program to find power of a number using math operation

Java program to find power of a number using math.pow

import java.util.Scanner;

Program:-

class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
int num1, num2;
double num;
System.out.println("Enter a number");
num1=data.nextInt();
System.out.println("Enter a power of the number");
num2=data.nextInt();
// Finding power of a number
num=Math.pow(num1,num2);
System.out.println("Answer:"+num);
}
}


Output:-

Enter a number
5
Enter a power of the number
3
Answer:125.0

Enter a number
567
Enter a power of the number
8
Answer:1.0682292637713283E22




Learn Java:-
Java codes

Java Programs:-
List of Java Programs

Leave reply

Add your comments here

Back to Top