Discussion
What will be the output of the program?
#include <stdio.h>
#define JOIN(s1, s2) printf("%s=%s %s=%s \n", #s1, s1, #s2, s2);
int main()
{
char *str1="India";
char *str2="BIX";
JOIN(str1, str2);
return 0;
}
Answer: B
Correct answer: str1=India str2=BIX
Each parameter is used twice: once with #, which stringizes the argument’s text, and once plainly, which yields the pointer. So #s1 becomes "str1" while s1 is the variable holding "India". The output is str1=India str2=BIX - the idiom used by debugging macros that print both a variable’s name and its value.
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