Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Array output question  RSS feed

 
pierre val
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any of you guys help me doing this problem

Show the output of the array


the answer to that problem is 13 15 19 9
can anyone show me how to calculate this ? and how the answer come up to be 13 15 19 9 ?

thank you

 
Krispin Kilmurray
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The second element of the array + the third is 13. a[i] + a[i+1]. i is = 1, 1 = second element of array, not first. Work out the rest of the loop from there. ;)
 
Ganish Patil
Ranch Hand
Posts: 529
19
Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Output is 13 15 19 if you print a[i] in that loop. Please go through this image link if still has problem please ask.
 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show the output of the array

I am not sure what is meant by this; an array does not "output".
After the loop is finished, if you print out the contents of the array you should get

3 13 15 19 9
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pierre val wrote:the answer to that problem is 13 15 19 9

No it isn't; as Fred already showed you.

The array starts with 5 elements, and it's not going to suddenly lose one because of what you're doing.

Winston
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!