+ 2
write the output int a[ 6]={5,7,2,9,6,8}; for(i=1;i<=2;i++) { s=a[i]+a[5-i]; System.out.println(s); }
Pls help me
5 Answers
+ 6
Please also use appropriate tags for programming language. Thanks!
+ 4
See how loop is working
When first time loop will run then i=1
s=a[1]+a[5-1] ; a[1]=7 and a[4]= 6 so 6+7= 13 same when second time loop will run then i++ so i will be 2
s=a[2]+a[5-2] ; a[2]= 2 and a[3] =9 so 2+9 =11
Hope u understood
+ 3
Please Don't write your Code in question It is hard to read and understand in that way.Please click on edit your question and then on plus icon and then Click on Insert Code to insert your Code.Then Everyone can understand your question and can answer you.
+ 2
you could just put this in the playground
+ 2
This is for you Sandra Sunil . You can save this code in your account. Please complete the Java tutorial. After that all will be easier.
https://code.sololearn.com/c7YSRyyvC7v2/?ref=app