As we know that arrays are passed by pointers only in C then swap1(arr[i],arr[j]) below means that two
pointers will be passed to the function swap1() then why swap1(arr[i],arr[j]) is giving me error? According to function prototype of swap1() two pointer should be passed and I am passing that.
On the other hand, when I am passing actually the address swap1(&arr[i],&arr[j]) it is working fine, which is obvious.
void swap1(int *a,int *b){
int temp = *a;
*a = *b;
*b = temp;
}
void bubble(int arr[], int i, int n)
{
for(int j=i+1;j<n;j++){
if(arr[i]>arr[j])
swap1(arr[i],arr[j]);
}
}
-Wall -Wextra -Werror), this should not compile.