closed by
430 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

1.2k
views
3 answers
0 votes
Aibi asked Oct 30, 2017
1,156 views
Consider the following program segmentint main(){char *str = "GATECS";printf("%d", madeeasy(str));return 0;}int madeeasy(int *p1){int *p2 = p1;while(*++p1);return p1-p2;}...
581
views
0 answers
0 votes
Pranavpurkar asked Sep 27, 2022
581 views
Which of the following is/are true regarding the following code snippet?1:int *p;2:p = &q; A)*p gives faster retrieval of information than q.B)The size of p is same as si...
659
views
0 answers
0 votes
abhinowKatore asked Dec 5, 2022
659 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 ));}
282
views
0 answers
0 votes