Discussion
What will be the output of the program ?
#include <stdio.h>
int main()
{
char *p;
p="hello";
printf("%s\n", *&*&p);
return 0;
}
Answer: B
Correct answer: hello
The operators * and & are inverses, so each adjacent pair cancels. Reading *&*&p from the right: &p gives the address of p, * takes us back to p, & takes the address again, and the final * returns to p.
The whole expression is therefore just p, and printf prints hello. Any even number of such pairs behaves the same way; the exercise exists to make the inverse relationship explicit.
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