Discussion
Point out the error in the following program.
#include <stdio.h>
int main()
{
char str[] = "IndiaBIX";
printf("%.#s %2s", str, str);
return 0;
}
Answer: D
Correct answer: No error
There is no error. %.#s and %2s are not the specifiers the author probably intended, but printf is not obliged to reject them - the format string is parsed at run time, and undefined or unrecognised conversions do not stop the program compiling. The array declaration is perfectly ordinary.
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