1.) Given int foo [50]; .... what is an equivalent way to represent: & foo [0] f
ID: 3754092 • Letter: 1
Question
1.) Given int foo [50]; .... what is an equivalent way to represent: & foo [0]
foo&
foo
foo [0]
None of the above
2.) Given an array defined as: int foo [5]; ... the following statement is never an issue: foo [5] = 12;
True
False
3.) Given the array: int foo [5] = {10,20,30,40, 50}; .... what would be printed from: printf ("%i", ++foo [3] );
30
31
40
41
4.) What is the array length (i.e., size) after this declaration: int foo [ ] = {10, 20, 40, 50, 60, 70};
4
5
6
7
a.)foo&
b.)foo
c.)foo [0]
d.)None of the above
Explanation / Answer
1. Answer: b. foo
Reason: &foo[0] points to the first element of the array foo and so does foo. That is why they are equivalent.
2. Answer: False
Reason: Arrays start from 0 in C. So when an array of length 5 is declared, the array contains elements from 0 to 4.
3. Answer: d. 41
Reason: foo[3] points to the 4th element, ie. 40. And when prefixed by ++, the value is incremented before being printer.
4. Answer: c. 6
Reason: When 6 elements are assigned to the array, the length of the array becomes 6(0 to 5).
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.