Discussion
Which of the following statements mentioning the name of the array does NOT yield the base address?
1. When array name is used with the sizeof operator.
2. When array name is operand of the & operator.
3. When array name is passed to scanf() function.
4. When array name is passed to printf() function.
Answer: B
Correct answer: 1, 2
The name of an array normally decays to the address of its first element - which is why passing it to scanf() or printf() gives the base address. There are two exceptions. With sizeof the name means the whole array, so sizeof(arr) gives the total number of bytes. With & it again means the whole array, so &arr has type “pointer to array”. Those are statements 1 and 2.
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