Answers for "power of a number in java"

3

how to find power of a number in java

int powerOfNumber = (int) Math.pow(number, power);
Posted by: Guest on March-07-2021
1

how to find powers in java

int n=Math.pow(N, P);
Posted by: Guest on June-28-2020
0

Java program to find the power of a number

@Test
	public void powerOfTheNumberProgram13() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("Enter any NUMBER: ");
		int number = scanner.nextInt();
		System.out.println("Enter the POWER: ");
		int power = scanner.nextInt();
		scanner.close();
		// Logic for finding the POWER of number
		int powerOfNumber = (int) Math.pow(number, power);
		System.out.println("Power of a " + number + "^" + power + ": " + powerOfNumber);
	}
Posted by: Guest on November-11-2020
0

power of a number in java

int base=2, power=5, result=1;
while(power != 0) {
	result = result * base;
	power--;
}
Posted by: Guest on May-16-2021
0

power of a number in java

int base=2, power=5, result=1;
for(int i = 1; i <= power; i++) {
	result = result * base;
}
Posted by: Guest on May-16-2021

Code answers related to "power of a number in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language