Discussion
Which of the following is the correct syntax to send an array as a parameter to function?
Answer: A
Correct answer: func(&array);
Of the four forms offered this is the only valid C that passes the array's address. &array yields a pointer to the whole array, which the function can receive as int (*)[N].
It is worth noting that the idiomatic form, func(array), is not among the options: an array name in an expression decays to a pointer to its first element, so writing the bare name already passes the address. The other options are not valid syntax at all, or pass a single element rather than the array.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development