C Programming - Arrays - Discussion

Discussion Forum : Arrays - General Questions (Q.No. 3)
3.
In C, if you pass an array as an argument to a function, what actually gets passed?
Value of elements in array
First element of the array
Base address of the array
Address of the last element of array
Answer: Option
Explanation:

The statement 'C' is correct. When we pass an array as a funtion argument, the base address of the array will be passed.

Discussion:
31 comments Page 1 of 4.

Fuad said:   2 years ago
The right answer is c) the base address of the array.
(2)

G.saikumari said:   4 years ago
I think C is the correct answer.
(3)

Reetika Chaudhary said:   7 years ago
If we look at the scanf() then we need to specify the (&) operator (which means address operator ) along with the array first from where we can access the elements and later on using printf() we need to pass only array elements . for eg : for reading the elements
int arr[5];

for(int i=0; i<=5;i++)
{
scanf(''%d '' , &arr[i])
}
for printing the elements
for (i=0;i<=5;i++)
{
printf(''%d'', arr[i])
}
(3)

Jyoti said:   8 years ago
I'm confused in either A or C can anyone explain?

Pranjali said:   8 years ago
Array elements can be passed to a function by calling the function by value or by reference.

In the call by value, we pass values of array elements to the function, whereas in the call by reference, we pass addresses of array elements to the function. So, the answer should be both A and C.
(1)

Suganthy said:   9 years ago
I also guess the same @Raji.

Raji said:   9 years ago
Please say the difference between the base address and first element?

As of my knowledge base address is nothing but an address of the first element.

Am I right?
(1)

Ch.Nagalaxmi said:   9 years ago
How to write with the logic base?

Vignesh P said:   10 years ago
Please answer any one, What is an argument in a array element?

Ashish said:   10 years ago
main( )
{
int i,a=2,b=3;
int arr[2+3];
for(i=0;i<a+b;i++)
{
scanf("%d",&arr[i]);
printf("\n%d",arr[i]);
}
}

Can you tell me the output of this program?
(2)


Post your comments here:

Your comments will be displayed after verification.