Discussion
What is the output of this C code?
int main()
{
printf("AllIndiaExams\r\nclass\n");
return 0;
}
Answer: B
Correct answer: AllIndiaExams class
The string contains \r\n between the two words. The carriage return returns the cursor to the start of the line and the newline moves it down one, so on a terminal the effect is simply to end the line - AllIndiaExams appears on one line and class on the next.
The carriage return alone would have returned to the start of the same line, so subsequent text would overwrite what was already there. Combined with the newline, its effect is invisible, which is why the two characters together are the conventional line ending on some systems.
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