+ 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

22nd Jul 2020, 12:00 PM
Sandra Sunil
Sandra Sunil - avatar
5 Réponses
+ 6
Please also use appropriate tags for programming language. Thanks!
22nd Jul 2020, 2:20 PM
Lothar
Lothar - avatar
+ 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
22nd Jul 2020, 5:45 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 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.
22nd Jul 2020, 12:20 PM
Akash Sharma
Akash Sharma - avatar
+ 2
you could just put this in the playground
22nd Jul 2020, 12:03 PM
Slick
Slick - avatar
+ 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
22nd Jul 2020, 12:23 PM
JaScript
JaScript - avatar