Discussion
What will be the output of the program if the array begins 1200 in memory?
#include <stdio.h>
int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0], &arr);
return 0;
}
Answer: B
Correct answer: 1200, 1200, 1200
All three expressions denote the same address, the start of the array: arr decays to &arr[0], &arr[0] is that address written out, and &arr is the address of the whole array, which begins at the same byte. Only their types differ, so all three print 1200.
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