ExamVeda
Login
Home
This question belongs to C Program C Miscellaneous
C Miscellaneous
?

Determine the Final Output:
void 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

Examveda
Question posted by Examveda
Community

Join the Discussion

11 Comments
Shuchi Gupta
Shuchi Gupta 3 years ago
What is r stands for n for newline b for backspace but can't get the clarity of r how the answer is (d) hai.
Someone pls explain
Deepak Goyal
Deepak Goyal 6 years ago
n - newline - printf("nab"); - Prints ab
b - backspace - firstly 'b' removes 'b' from 'ab ' and then prints 'asi'.
r - currsor point to start and then ha overrides as and then print hai
Dev Sharma
Dev Sharma 7 years ago
I am getting your point clearly
Shubham Soni
Shubham Soni 9 years ago
why
skip only first 2 spaces
Pulkit Sachdeva
Pulkit Sachdeva 9 years ago
i am getting absiha at repl.it and codefroblocks.
Pavan Kalyan
Pavan Kalyan 9 years ago
I am not able to get answer that you specified , I am getting absiha, I tried in different compilers but getting the same answer
Pavan Kalyan
Pavan Kalyan 9 years ago
I am not able to get answer that you specified , I am getting absiha
Kakkar Mohit
Kakkar Mohit 9 years ago
Now, a carriage return means to go back to the beginning of the line. So the "ha" overwrites the "as" in "asi:
Barbarous Pranav
Barbarous Pranav 10 years ago
Exact Solution...

ab
b : back one character
write si : overrides the b with s (producing asi on the second line)
r : back at the beginning of the current line
write ha : overrides the first two characters (producing hai on the second line)


Ameen Althaf
Ameen Althaf 10 years ago
no, if u don't put /r then it should be print as "asiha",
in our program in last statement we have /r so it removes first two character an prints ha in place of it therefore output is 'hai'
Mala Gowda
Mala Gowda 10 years ago
As per the example answer is "asiha" right?