New course! Every coder should learn Generative AI!
Try a free lesson0
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--; } } }
2 Answers
+ 3
What is your question?
+ 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