Discussion
Output of following C program?
#include <stdio.h>
#define max abc
#define abc 100
int main()
{
printf("maximum is %d", max);
return 0;
}
Answer: A
Correct answer: maximum is 100
Two rules combine. First, a macro is rescanned after substitution, so max expands to abc and abc then expands to 100. Second, macro replacement applies to tokens, not to text inside a string literal - so the max inside "maximum is %d" is untouched. The output is maximum is 100.
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