closed by
397 views

2 Answers

2 votes
2 votes
The concept involved in the question is that arrays are passed by pointers and so when we pass an array to fun() we will actually be passing a pointer of that array.
The answer to this question would depend on the implementation of data types by the machine/compiler and amount of bytes given to each.As per the solution it seems they have taken pointers as 4 bytes and integers as 2 bytes. So arr_size evaluates to 2 ,(notice that even though syntax of fun(int arr[]) when passed would be converted to a pointer int *arr and its size would be 4 bytes.)
so as arr_size evaluates to 2 first 2 elts will get printed.

Related questions

0 votes
0 votes
3 answers
1
0 votes
0 votes
0 answers
2
0 votes
0 votes
0 answers
3
abhinowKatore asked Dec 5, 2022
632 views
What will be the return value of the below function, if it is called a sample(4)? int sample(int x){ if( x == 0 || x ==2) return 1; return (sample( x) * (x ));}
0 votes
0 votes
0 answers
4