I got this question asked by one of my peer, as i don't know "C" that much, but still being a beginner i tried solving it, this is the approach i used, but it is not giving the expected output.
According to the question, it should print the entered elements of an array, when we are passing the reference of an array to a function, can anyone review this code ?
#include <stdio.h>
void print(int arr[], int n);
int main(){
int n,i;
int arr[n];
printf("enter the size of array :");
scanf("%d",&n);
printf("enter elements :\n");
for(i=0; i<n; i++){
scanf("%d",&arr[i]);
}
print(&arr[i], n);
}
void print(int arr[], int n){
int i;
for(i=0; i<n; i++){
printf("\nentered elements are : %d",arr[i]);
}
}