Java Code To Check Power Of Two Numbers. Ex: i/p 5 and 8 o/p 5^8=?

March 14, 2023

Program:

public class Power 
{
	public static void main(String[] args) 
	{
		int a = 5, b = 8;
		int n = 1;
		for (int i = 1; i <= 8; i++) 
		{
			n = n * a;
		}
		System.out.println(n);
	}
}

Compile:

javac Power.java
 java Power

Output:

390625

You Might Also Like