?
What will be printed after execution of the following program code?
What will be printed after execution of the following program code?
main()
{
printf("\\nab");
printf("\\bsi");
printf("\\rha");
}
main()
{
printf("\\nab");
printf("\\bsi");
printf("\\rha");
}
Answer & Solution
Correct Answer:
Option
D
\\n - newline - printf("\\nab"); - Prints 'ab'
\\b - backspace - printf("\\bsi"); - firstly '\\b' removes 'b' from 'ab ' and then prints 'si'. So after execution of printf("\\bsi"); it is 'asi'.
\\r - linefeed - printf("\\rha"); - Now here '\\r' moves the cursor to the start of the current line and then override 'asi' to 'hai' .
\\b - backspace - printf("\\bsi"); - firstly '\\b' removes 'b' from 'ab ' and then prints 'si'. So after execution of printf("\\bsi"); it is 'asi'.
\\r - linefeed - printf("\\rha"); - Now here '\\r' moves the cursor to the start of the current line and then override 'asi' to 'hai' .
Join the Discussion
Login to post a comment or share your explanation.
Loginonly single slash
main()
{
printf("nab"); /* n for newLine */
printf("bsi"); /* b for backspace */
printf("rha"); /* r moves the cursor to the start of the current line*/
}
We are kindly informing you to use single backslash ( ) instead of double backslash ( )
{
printf("
ab");
printf("si");
printf("
ha");
}
answer is- E because output is -
absi
ha
_________________________________________
main()
{
printf("
ab");
printf("si");
printf("
ha");
}
answer is- D because output is - hai
bcause on execution of this code o/p comes out to be "ha"