Discussion
#include <stdio.h>
#define a 10
int main()
{
printf("%d ",a);
#define a 50
printf("%d ",a);
return 0;
}
Answer: B
Correct answer: 10 50
The preprocessor works line by line, top to bottom, so the first printf is expanded while a still means 10 and the second after it has been redefined to 50. The output is 10 50. Redefining a macro to a different value without an intervening #undef is not strictly conforming, so a compiler will warn.
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