find int a[]={9^10, 4^9, 1^8, 2^7, 7^6, 2^5, 3^4, 7^3, 6^2, 9^1}; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

find int a[]={9^10, 4^9, 1^8, 2^7, 7^6, 2^5, 3^4, 7^3, 6^2, 9^1};

public class Power1_array { public static void main(String args[]) { int a[]={9,4,1,2,7,2,3,7,6,9}; int pow=1, pos=10; for(int i=0; i<a.length;i++) { for(int j=1; j<pos; j++) { pow*=a[i]; } System.out.println("Power="+(pow)); pos--; } } }

8th Mar 2023, 5:12 PM
Sahil Kshirsagar
Sahil Kshirsagar - avatar
2 Answers
+ 3
What is your question?
8th Mar 2023, 6:14 PM
Lisa
Lisa - avatar
+ 1
u have to do something like this your power is in decreasing order Start loop from 10 till 1 for i in 1...10 .reverse{ power(a[i] , i) } Also change the type of data which u have taken int might be u will face range issue
8th Mar 2023, 6:27 PM
A S Raghuvanshi
A S Raghuvanshi - avatar