as name00 name10 name20 name40 name01 name11 name39 name49 In the first case

As name00 name10 name20 name40 name01 name11 name39

This preview shows page 1 - 3 out of 5 pages.

as name[0][0], name[1][0],  name[2][0]…, name[4][0], name[0][1], name[1][1],…, name[3][9], name[4][9]. In the first case, grades is an  integer  array of size 5 X 10 = 50. The elements can be referenced by  using   2 subscripts   as grades[1][9], grades[4][9]. The   first   element is grades[0][0] and the   last   element is grades[4][9]. Similarly, the letter is an array of  characters   of size 40 with  last  element  being letter[9][3]; xyz is an array of  float  of size 2500 with  last  element being xyz[99][24]. The two-dimensional arrays can be  initialized   as int  x [3] [2] = { 12, 56, 67, 4, 6 ,78 } ; 1
Image of page 1
where  the x[0][0] = 12, x[0][1] = 56, x[1][0] = 67, x[1][1] = 4, x[2][0] = 6, x[2][1] = 78. As with  single dimension arrays  if the initial values are less than the size of array the remaining values are set to 0 .   How to read and print 2-D Array using two for loops ?: The two-dimensional arrays can also be initialized by using for loop. To initialize, read and print two-dimensional arrays we need  two for loops . The  first loop controls  the first subscript  and the  second loop controls the second subscript.   Consider the following  example: int abc[5][10] , i, j ; for ( i = 0 ; i < 5 ; ++ i )
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 5 pages?

  • Spring '10
  • zaman
  • Array

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes