What is the relation between array name and an element number.

Showing Answers 1 - 12 of 12 Answers

Manohar

  • Nov 17th, 2007
 

Array name is the pointer to the first element of the array.
when you say *aiNumber it will give you value of first element of the array.
*(aiNumber+3) is same as aiNumber[3]...

  Was this answer useful?  Yes

baseersd

  • Nov 19th, 2007
 

Array name is nothing but
  1 ) The address of the array
  2 ) Address of the first element of the array.

Element number is the offset of the element. Which means, to get the element of the array , we have to increment the base address of the array with the offset.

Here is an example.

int arr[5]={10,20,30,40,50};

arr will hold the address of the array.
*arr == arr[0];

Here to access the first number of the array, no need to increment. Hence, the offset if zero.

Similarly, to access 3rd element,
arr[2].

  Was this answer useful?  Yes

Joe

  • Nov 20th, 2007
 

The relationship between an array element and the elements index number is as follows.

     1. The array name by itself is a constant pointer to the first element of the array.

         So if you have this int iary[4] = { 10, 22, 4, 17 } then 'iary' is a constant

         pointer to the value 10, so *iary == '10';

     2. An array elements index represents an offset in the array to that element.

         So if you have an element index of 2 for the above array (iary), then        

         iary[2] == 4.  Notice it does not equal 22.  In 'c' array indexing starts at 0.

         Because array indexing starts at 0, iary[0] == 10, iary[1] ==22,
         iary[2] == 4, and iary[3] == 17

        

  Was this answer useful?  Yes

jintojos

  • Jun 9th, 2008
 

Array name is the base address of the aaray. By using this base address we can refer to the array elements. that is a[0] means "base address + 0th" element. that is array element number is the distence from the base address to the specified data 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions