Discussion
What will be the output of the following statement ?
int a = 10; printf("%d &i", a,10);
Answer: D
The output is 10 &i, so the answer is None of the above.
The format string "%d &i" contains only one conversion specifier, %d, which prints the value of a, 10. The rest, a space followed by the characters &i, is ordinary text and is printed as it stands. The extra argument 10 has no specifier to use it and is ignored; C allows surplus arguments to printf.
'10 10' would be the output of "%d %i"; with & instead of % the second number is never printed. The statement compiles, so it is not an error.
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