Discussion
Comment on the code below
#include <stdio.h>
void main()
{
int x = 5;
if (true);
printf("hello");
}
Answer: B
Correct answer: It will throw an error
true is not a keyword in C. It is a macro defined in <stdbool.h>, which this program does not include, so the identifier is undeclared and the program fails to compile. (Had it compiled, the semicolon after the if would have been the empty statement forming its branch, and hello would have printed unconditionally.)
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