Determine the Final Output:
void main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
void main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
A. absiha
B. asiha
C. haasi
D. hai
Answer: Option D
Solution(By Examveda Team)
\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
Join The Discussion
Comments ( 10 )
Related Questions on C Miscellaneous
Determine output:
void main()
{
int const *p=5;
printf("%d", ++(*p));
}
A. 6
B. 5
C. Garbage Value
D. Compiler Error
A. mmm nnn aaa
B. mmmm nnnn aaaa
C. Compiler Error
D. None of These
A. I hate Examveda
B. I love Examveda
C. Error
D. None of These
Determine Output:
void main()
{
static int var = 5;
printf("%d ", var--);
if(var)
main();
}
A. 5 5 5 5 5
B. 5 4 3 2 1
C. Infinite Loop
D. None of These
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
I am getting your point clearly
why
skip only first 2 spaces
i am getting absiha at repl.it and codefroblocks.
I am not able to get answer that you specified , I am getting absiha, I tried in different compilers but getting the same answer
I am not able to get answer that you specified , I am getting absiha
Now, a carriage return means to go back to the beginning of the line. So the "ha" overwrites the "as" in "asi:
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)
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'
As per the example answer is "asiha" right?