ACtE03 · Chapter 3Programming & Applications🏛️ Past Licensure QuestionID: 6ed5003f
Which of the following is the standard syntax to pass an array arr as an argument to a function void func(int *p) in C?
Which of the following is the standard syntax to pass an array arr as an argument to a function void func(int *p) in C?
Multiple Choice Options
- A✓ Correct Option
func(arr);
- B
func(#arr);
- C
func(*arr);
- D
func(arr[size]);
Detailed Technical Solution & Explanation
In C, passing an array to a function expecting a pointer is done by simply specifying the array name: func(arr);. The identifier arr automatically decays into a pointer to its first element (&arr[0]).
Option Analysis:
•
Option A (;): Correct. Passes the decayed pointer to the base address of
arr.•
Option B (;):
# is the preprocessor stringification operator, invalid in C expressions.•
Option C (;): Passes the value of the first element (
arr[0]), not the array pointer.•
Option D (;): Passes a single out-of-bounds element, not the array pointer.
Reference: Mock Test 04NEC Licensure Syllabus