Discussion
Point out the error in the program
#include <stdio.h>
int main()
{
int i;
#if A
printf("Enter any number:");
scanf("%d", &i);
#elif B
printf("The number is odd");
return 0;
}
Answer: A
Correct answer: Error: unexpected end of file because there is no matching #endif
Every #if, #ifdef or #ifndef must be closed by an #endif. Here the conditional started by #if A and continued by #elif B is never closed, so the preprocessor runs off the end of the file and reports it. Note that this is a preprocessing error, so it is reported before any of the C is looked at.
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