We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 723d0d4 commit a967022Copy full SHA for a967022
Test19_power_calculation_program.java
@@ -0,0 +1,41 @@
1
+package com.test.Basic_Java_Programs;
2
+
3
+import java.util.Scanner;
4
5
+public class Test19_power_calculation_program
6
+{
7
8
+ public static void main(String[] args)
9
+ {
10
+ int n,p,result=1;
11
12
+ System.out.print("Enter any Number : ");
13
14
+ Scanner sc = new Scanner(System.in);
15
16
+ n = sc.nextInt();
17
18
+ System.out.print("Enter Power : ");
19
20
+ p = sc.nextInt();
21
22
+ for (int i = 1; i <=p; i++)
23
24
+ result = n*result;
25
26
+ }
27
28
+ System.out.println("Power " + result);
29
30
31
+}
32
33
34
+/* Output:
35
36
+Enter any Number : 5
37
+Enter Power : 2
38
+Power 25
39
40
41
+*/
0 commit comments