• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Two dimesnsional array question  RSS feed

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the two dimensional arraydefined as int[2][20]; that represents the starting and ending locations of 20 programs. you would refer to the ending address of thord program as:
a. addr[2][20]
b. addr[1][2]
c. addr[2][1]
d. addr[2][3]
e. addr[3][2]

Ans is (b) . Can anyone explain why??
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you mind Re-Phrasing your question?
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The indexes start at zero so addr[0][0] would be the starting point of the first program. The ending point of program x would be addr[1][x], so the ending point of the third program would be addr[1][2].
 
Chiran Mathur
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Lisa, I think I oretty much understood this.So o would always reprsent the starting address and 1 the ending and x would represent the program no right?
Thanks.
 
Lisa Yanchunis
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes but x = Program# less one because the index starts at 0 so for program 1 x=0, prgroam 2 x=1 etc until program 20 x=19. (using x=20 would give index out of bounds exception but that is another question)
Lisa
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!