diff --git a/src/navs/program.js b/src/navs/program.js index 82fb2610..323ed8f2 100644 --- a/src/navs/program.js +++ b/src/navs/program.js @@ -17,5 +17,7 @@ export const programsNav = { pages['java-program-to-check-Leap-year'], pages['calculate-simple-interest'], pages['java-program-to-check-divisbility'], + pages['find-quotient-and-reminder'], + pages['calculate-power-of-a-number'], ], } diff --git a/src/pages/programs/calculate-power-of-a-number.mdx b/src/pages/programs/calculate-power-of-a-number.mdx new file mode 100644 index 00000000..53b8e6ac --- /dev/null +++ b/src/pages/programs/calculate-power-of-a-number.mdx @@ -0,0 +1,40 @@ +--- +title: Java Program to calculate power of a number +shortTitle: Calculate power of a number +description: In this program you'll learn, How to calculate power of a number +--- + +To understand this example, you should have the knowledge of the following Java programming topics: + +- [Java Operators](/docs/operators) +- [Java Basic Input and Output](/docs/basic-input-output) +- [Control Flow statement - For-Loop in Java](/docs/for-loop) +## Calculating power of a number +A java program to calculate the power of a number is as follows: + +```java +public class power { + public static void main(String[] args){ + java.util.Scanner input = new java.util.Scanner(System.in); + System.out.print("Base Number: "); + int baseNumber = input.nextInt(); + System.out.print("Power of : "); + int powerOf = input.nextInt(); + int output = baseNumber; + for(int i=1;i + +Don't know how to take input from the user ? Look at [this examples](/docs/basic-input-output#java-input) + +Here two input numbers are taken from user one after another with space in between them which distinguish between two different inputs, this useful behavior is because of the default settings of Scanner called as Delimiter, [learn more here](https://www.javatpoint.com/post/java-scanner-delimiter-method). + +