Passing of an array

void selection(int a[], int n) {

for (int i = 0; i < n - 1 ; i++) {
	int min_index = i ;

	for (int j = i ; j <= n - 1 ; j++) {
		if (a[j] < a[min_index])
			min_index = j;
	}

	swap(a[i], a[min_index]);
}

}

int main() {

int n , key;

cin >> n;

int a[1000];

for (int i = 0 ; i < n; i++) {
	cin >> a[i];
}

selection(a, n);

for (int i = 0 ; i < n ; i++) {
	cout << a[i] << " ,";
}

return 0;

}

#In the particular code the array is passed by reference or by value

hello @princeguptaa
it is passed as pointer.

read the difference between pass by value/refernce/pointer

could you plzz provide some links or article related to array passed as pointer because I can’t find one

void fun(int *brr){
---- some logic----
}

int arr[n];
fun(arr);
this is an example . (btw array is always passed as pointer)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.