Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
C code; pass by value, reference and value-result?
void swap(int list[], int i, int j) {
int temp= list[i];
list[i]= list[j];
list[j] =temp;
}
int main(void) {
int x[3] ={5, 2, 4};
swap(x, 1, 2);
}
What is the final value of the array x for each of the following parameter passmg assumptions?
(a) Argument xis passed by value.
(b) Argument x is passed by reference.
2 Answers
- ?Lv 79 years agoFavorite Answer
Sorry if you take definition of the pass by value valid here, then array is not supposed to change.
However, in fact in C language array names are pointers to the addresses. When we are sending arrays to a function means, we are really sending their addresses only. There is no concept of reference variables in C language