C Programming - Arrays - Discussion
|
|
|
|
Read more:"I never think of the future. It comes soon enough."
- Albert Einstein
|
| 3. |
In C, if you pass an array as an argument to a function, what actually gets passed? |
| [A]. |
Value of elements in array | | [B]. |
First element of the array | | [C]. |
Base address of the array | | [D]. |
Address of the last element of array |
Answer: Option A
Explanation:
The statement 'C' is correct. When we pass an array as a funtion argument, the base address of the array will be passed.
|
|
Ganesh said:
(Sun, Aug 14, 2011 01:02:43 PM)
|
|
| |
| Since arrays name represent its base adress. |
|
Shakil said:
(Wed, Aug 24, 2011 02:23:06 PM)
|
|
| |
| Can anyone exaplin this in detail please. |
|
Sameera said:
(Sat, Jan 28, 2012 11:50:12 AM)
|
|
| |
Take a[5], it will store address of a[0] in a. when it will access the array only by a it will increment a or it will take a+1,a+2,a+3 and so on.
When array is passed to any function we will pass as
add(a);
In definition it will take it in pointer and access whole array
Hence at the time of passing array it will pass only base address i.e. address of first element of array. |
|
|