Discussion
What is the output of the below code snippet?
#include <stdio.h>
main()
{
unsigned x = 5, y=&x, *p = y+0;
printf("%u",*p);
}
Answer: D
Correct answer: 5
y holds the address of x, and p is set to that same address, so *p is x itself - 5. (The code stores an address in an unsigned int, which is poor practice and provokes warnings; it happens to work only where a pointer and an unsigned int are the same width.)
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