GeeksforGeeks
geeksforgeeks.org โบ java โบ java-program-to-calculate-power-of-a-number
Java Program to Calculate Power of a Number - GeeksforGeeks
// Java program to find the power of a number // using Recursion class GFG { // Function to calculate N raised to the power P static int power(int N, int P) { if (P == 0) return 1; else return N * power(N, P - 1); } // Driver code public static ...
Published ย July 12, 2025
Programiz
programiz.com โบ java-programming โบ examples โบ power-number
Java Program to Calculate the Power of a Number
Here, instead of using a while loop, we've used a for loop. After each iteration, the exponent is decremented by 1, and the result is multiplied by the base exponent number of times. Both programs above do not work if you have a negative exponent. For that, you need to use the pow() function ...
W3Schools
w3schools.in โบ java โบ examples โบ calculate-the-power-of-any-number-in-the-java-program
Calculate the Power of Any Number in the Java Program
Using While Loop we keep multiplying temp by besanumber until the exponent becomes zero.
TutorialsPoint
tutorialspoint.com โบ Java-program-to-calculate-the-power-of-a-number
Java program to calculate the power of a number
import java.util.Scanner; public class PowerOfNumber { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter the base number ::"); int base = sc.nextInt(); int temp = base; System.out.println("Enter the exponent number ::"); int exp = sc.nextInt(); ...
W3codeworld
w3codeworld.com โบ article โบ 177 โบ java-program-to-calculate-the-power-of-n-number-using-for-loop-and-by-using-pow-function
Find Power of a Number in Java using For loop - W3CODEWORLD
// Find Power of a Number in Java using Math.pow() Function import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); double b, x, r; // b - To store base number // x - To store exponent number // r - To store result value ...
BeginnersBook
beginnersbook.com โบ 2019 โบ 09 โบ java-program-to-calculate-power-of-a-number
Java Program to Calculate Power of a Number
In the following program, we are using pow() function to calculate power. public class JavaExample { public static void main(String[] args) { int number = 10, p = 3; double result = Math.pow(number, p); System.out.println(number+"^"+p+" = "+result); } } ... 1. Java program to find quotient ...
Top answer 1 of 2
3
Try this.
double t = 1;
double b = 2; // base number
double exponent = 2;
for (int i = 1; i<=exponent; i++) t = t*b;
System.out.println(t);
2 of 2
0
It's because the first iteration around you are setting T equal to B. You aren't multiplying by the exponent just yet. So it needs to iterate 1 further time then you are expecting. just decrease the I value in your for loop. EG
for(int i = 1; i <= exponent; i++)
t=t*b;
Hope this helps!
WsCube Tech
wscubetech.com โบ resources โบ java โบ programs โบ power-number
Java Program to Calculate the Power of a Number (7 Ways)
October 19, 2025 - Explore 7 different Java programs to calculate the power of a number. Learn methods using for loops, recursion, Math.pow(), and more. Ideal for learners!
YouTube
youtube.com โบ watch
Power of a Number in Java || Explained using loop and Math.pow() function - YouTube
#power of a #Number in Java using for loop and also using math.pow.Video Highlights:How do you find the power of a number in Java?How do you find the power o...
Published ย August 23, 2022
Techcrashcourse
techcrashcourse.com โบ 2022 โบ 11 โบ java-program-find-power-of-number.html
Java Program to Calculate the Power of a Number
In this java program, we will learn about how to calculate the power of a number using loops, using Math.pow() method and using recursion.
TutorialKart
tutorialkart.com โบ java โบ java-calculate-power-of-number
Java Program to Calculate Power of a Number
November 23, 2020 - To calculate power of a number, you can either user Math function pow(), or use a for loop, to multiply the number given number of times. pow() takes two numbers as arguments and calculate the first argument raised to the power of second argument.
Javatpoint
javatpoint.com โบ power-of-a-number-in-java
Power of a Number in Java - Javatpoint
Power of a Number in Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
YouTube
youtube.com โบ slidenerd
37 Java Program Power Using For Loops | - YouTube
Launch Your First Android app with our TOP course at 82% OFF (24 hrs ONLY) HERE https://goo.gl/7veBXc "Learn How To Design + Code A Complete App From Scratch...
Published ย January 29, 2013 Views ย 13K