Discussion
What is the output of this program?
#include <stdio.h>
#define p 17;
int main()
{
printf("%d",p);
return 0;
}
Answer: D
Correct answer: Compilation error
The macro body is 17; - semicolon included. Substituting it gives
printf("%d",17;);
which is a syntax error. This is why a #define for a constant should never end with a semicolon: the macro is text, and the semicolon travels with it wherever the name is used.
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