1 Array 2 Array3 3 Array3 4 Array3 5 int Array10 6 int x 7 i
1. Array
2. Array[3]
3. &Array[3]
4. *(&Array[3])
5. int Array[10];
6. int x;
7. int* px;
8. &x
9. *px
10. x
Illustration 1: Declarations and References
1. Illustration 1: Which line declares an array?
2. Illustration 1: Which line declares an integer?
3. Illustration 1: Which line declares an integer pointer?
4. Illustration 1: Which line gives the value of the fourth element of an array?
5. Illustration 1: Which line gives the address of the third subscripted value of an array?
6. Illustration 1: Which line specifies the value of an integer?
7. Illustration 1: Which line gives the pointer to the first element of an array?
8. Illustration 1: Which line gives the contents of the address of the fourth element of an array?
9. Illustration 1: Which line gives the address of an integer?
10. Which line dereferences (gives the contents) of an address given by an integer pointer?
1. int x;
2. int cherry[10];
3. foo(x);
4. foo(&x);
5. foo(cherry[3]);
6. foo(cherry, 3);
7. foo(&cherry[3]); Illustration 2: Function calls
11. Illustration 2: Which line declares an integer? 12. Illustration 2: Which line declares an array with 10 elements?
13. Illustration 2: Which line calls foo with a copy of an integer?
14. Illustration 2: Which line calls foo with the address of an integer?
15. Illustration 2: Which line calls foo with the address of the first element of an array?
16. Illustration 2: Which line calls foo with the value of an element of an array?
17. Illustration 2: Which line calls foo with the address of an element of an array which is not the first element?
Solution
1.Line 5 : int Array[10];
Explanation : The above statement declares an array named Array of type integer of size 10.
--------------------------------------------------------------------------------------------------
2. Line 6: int x;
Explanation : The above statement declares integer variable
--------------------------------------------------------------------------------------------------
3. Line 7 : int *px;
Explanation : The above statement declares integer pointer that stores the address of integer variable.
--------------------------------------------------------------------------------------------------
4. Line 2: Array[4]
Explanation : The above statement gives the fourth element of an array, Array
--------------------------------------------------------------------------------------------------
5. Line 3: &Array[4]
Explanation : The above statement gives address of the third subscripted value of an array.
--------------------------------------------------------------------------------------------------
6. Illustration 10:x
Explanation : the variable x speicies the value at the variable .x.
--------------------------------------------------------------------------------------------------
7. Line 1:Array
Explanation : the array name itself represents the address of the first element of the array.
--------------------------------------------------------------------------------------------------
8.Line 4: *(&Array[3])
Explanation : The above statement gives the value of the array at the address of the third subscript
--------------------------------------------------------------------------------------------------
9. Line 8: &x
Explanation : & before the variable returns the address of the variable in memory.
--------------------------------------------------------------------------------------------------
10. Line 9: *px
Explanation : The * dereferencing operator that gives the contents of an address given
by an integer pointer,px.
---------------------------------------------------------------------------------------------------------
11. Line 1: int x
Explanation : The above statement declares integer variable
---------------------------------------------------------------------------------------------------------
12.Line 2 : int cherry[10];
Explanation : The above statement declares an array named cherry of type integer of size 10.
---------------------------------------------------------------------------------------------------------
13. Line 3: foo(x);
Explanation : the above statement foo(x) that takes an element x
---------------------------------------------------------------------------------------------------------
14. Line 3: foo(&x);
Explanation : the above statement foo(&x) that takes an address of element x
---------------------------------------------------------------------------------------------------------
15. No answer for this question in given illustrations.
---------------------------------------------------------------------------------------------------------
16. Line 5: foo(cherry[3])
Explanation: The above statement calls the foo method with the element of the array cherry[3]
---------------------------------------------------------------------------------------------------------
17. Line 5: foo(7cherry[3])
Explanation: The above statement calls the foo method with the addresss of element of the array
cherry[3]element?
![1. Array 2. Array[3] 3. &Array[3] 4. *(&Array[3]) 5. int Array[10]; 6. int x; 7. int* px; 8. &x 9. *px 10. x Illustration 1: Declarations and Refere 1. Array 2. Array[3] 3. &Array[3] 4. *(&Array[3]) 5. int Array[10]; 6. int x; 7. int* px; 8. &x 9. *px 10. x Illustration 1: Declarations and Refere](/WebImages/16/1-array-2-array3-3-array3-4-array3-5-int-array10-6-int-x-7-i-1028061-1761532489-0.webp)
![1. Array 2. Array[3] 3. &Array[3] 4. *(&Array[3]) 5. int Array[10]; 6. int x; 7. int* px; 8. &x 9. *px 10. x Illustration 1: Declarations and Refere 1. Array 2. Array[3] 3. &Array[3] 4. *(&Array[3]) 5. int Array[10]; 6. int x; 7. int* px; 8. &x 9. *px 10. x Illustration 1: Declarations and Refere](/WebImages/16/1-array-2-array3-3-array3-4-array3-5-int-array10-6-int-x-7-i-1028061-1761532489-1.webp)